Click to See Complete Forum and Search --> : Why is this not working?


gogelpot
10-18-2006, 03:44 AM
Hi I am updating a DB with a php script. The db is large and therefore I refresh the page after every 500 entrys have been updated.

$x = 0;
while ($x < $num){
$x++;
if ($x == 500){
header('Location: http://127.0.0.1/FC Data/tempbat1.php?Flag=1');
}
}


If I add a exit statment and leaving out the header('Location: http://127.0.0.1/FC Data/tempbat1.php?Flag=1'); statment in the IF($x == 500) it does exit. But with header('Location: http://127.0.0.1/FC Data/tempbat1.php?Flag=1'); statment alone in the If {} it does not redirect the page. It is as if the if ($x == 500){ } does not exist, it continues with the script after the if ($x == 500){ } statment. So the page is not refreshed.

Could someone please help me.

john_de116
10-18-2006, 04:15 AM
The code is correct. But you have to add the "exit;" in that block. Please try the following code. It will work exactly.

$x = 0;
while ($x < $num){
$x++;
if ($x == 500){
header('Location: http://127.0.0.1/FC Data/tempbat1.php?Flag=1');
exit;
}
}

pcthug
10-18-2006, 04:16 AM
Is any output sent to the browser before you try to redirect the user?

gogelpot
10-18-2006, 04:27 AM
Thanks that did the trick.