...

View Full Version : PHP MySQL and Header Redirection Problem! (Please Help)



Element
09-11-2005, 10:07 AM
Well the error with this, is the header("Location: ".$url); doesn't work, and even when I use a Javascript version it still doesn't work. I think it might have to do witht he enclosing PHP. Please help me. Here is the code that has the error.



<?php

$username = "****";
$password = "****";
$database = "****";

if ($_GET['go'] !== "") {

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM go WHERE id='$go'";
$result=mysql_query($query);

$num=mysql_num_rows($result);

mysql_close();

$i=0;
while ($i < $num) {

$url=mysql_result($result,$i,"url");

echo '<script language="JavaScript">'; //Testing JavaScript
echo '<!--';
echo 'window.location="'.$url.'"';
echo '//-->';
echo '</script>';


$header = header("Location: ".$url); // Not testing anymore


$i++;
}

}
else {

?>

e-Raser
09-11-2005, 12:09 PM
Take away the $header =

Yaggles
09-11-2005, 02:22 PM
Also, header MUST be called before ANY data is outputted on the screen (before any echo's, print's, ect.)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum