not redirecting

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
m2babaey
Forum Contributor
Posts: 364
Joined: Sun May 20, 2007 9:26 am

not redirecting

Post by m2babaey »

Hi
I use a page for some analysis and then redirect the user to the correct url. but the users are not redirected.
the first url that is called is similar to:
http://127.0.0.1/adcenter/clicks.php?ad ... &listing=8
and the page clicks.php is :

Code: Select all

<?php
include 'global.php';
$adid=clean($_GET['adid']);
$publisher=clean($_GET['publisher']);
$advertiser=clean($_GET['advertiser']);
$listing=clean($_GET['listing']);
$sql="SELECT * FROM adsetting WHERE id='$adid'";
$result=mysql_query($sql)or die (mysql_error());
$row=mysql_fetch_array($result);
$keyword=$row['keyword'];
$price=getcost($keyword,$listing);
$sql2="SELECT * FROM advertiser WHERE id='$advertiser' ";
$result2=mysql_query($sql2) or die (mysql_error());
$row2=mysql_fetch_array($result2);
$advertiserbalance=$row2['balance'];
if ($advertiserbalance<$price) echo "The advertiser does not have enough balance in his/her account";
else{
$advertiserbalance-=$price;
$sql3="SELECT * FROM publisher WHERE id='$publisher' ";
$result3=mysql_query($sql3) or die (mysql_error());
$row3=mysql_fetch_array($result3);
$publisherbalance=$row3['balance'];
$price=$price*3/4 ;
$publisherbalance+=$price;
$sqlu1= "UPDATE advertiser SET balance='$advertiserbalance' WHERE id='$advertiser'";
$resultup1=mysql_query($sqlu1) or die(mysql_error()) ;
if (!$resultup1) echo "There was a problem during the analysis. Please contact us to inform aout the issue";
else{
$sqlu2= "UPDATE publisher SET balance='$publisherbalance' WHERE id='$publisher'";
$resultup2=mysql_query($sqlu2) or die(mysql_error()) ;
$sql4="SELECT * FROM listing WHERE id='$listing' ";
$result4=mysql_query($sql4) or die (mysql_error());
$row4=mysql_fetch_array($result4);
$url=$row4['url'];
header("Location : $url "); 
}
}
?>
when i enter that url in the address bar, the result is not $url. why?
mcog_esteban
Forum Contributor
Posts: 127
Joined: Tue Dec 30, 2003 3:28 pm

Post by mcog_esteban »

Instead of

Code: Select all

header("Location : $url ");

Code: Select all

header("Location: $url");
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post by Begby »

What is happening? Are you getting a blank page? You getting any errors?
m2babaey
Forum Contributor
Posts: 364
Joined: Sun May 20, 2007 9:26 am

Post by m2babaey »

yes
a blank page
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Post by Zoxive »

Code: Select all

 ....
echo $url; // Is it outputting a correct url?
//header("Location: $url");
m2babaey
Forum Contributor
Posts: 364
Joined: Sun May 20, 2007 9:26 am

Post by m2babaey »

i tested it before.
it echoes the $url so the right if statement is running
mcog_esteban
Forum Contributor
Posts: 127
Joined: Tue Dec 30, 2003 3:28 pm

Post by mcog_esteban »

I've tryed

Code: Select all

header("Location : $url");
and got a HTTP/1.1" 200 -
But with a blank.

Sorry...got mistaken.
m2babaey
Forum Contributor
Posts: 364
Joined: Sun May 20, 2007 9:26 am

Post by m2babaey »

mcog_esteban wrote:I've tryed

Code: Select all

header("Location : $url");
and got a HTTP/1.1" 200 -
But with a blank.

Sorry...got mistaken.
what does it mean?
Post Reply