NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP REDIRECT

bz-gmort at beezifies.com bz-gmort at beezifies.com
Wed Sep 5 07:58:06 EDT 2007


PaulCheung wrote:
> .
> if ($number_of_records == 0)
>    {$link = "http://localhost/mainmenu.php";}
>
> I have also tried
> header('Location: http://localhost/mainmenu.php);

For the first, I generally find it best to place an "echo $link" first 
to make sure it is being set to what I think it should be set to.  Than 
following that with replacing the echo with a meta-refresh and a 
countdown timer to see if that works, and do the the header call 
last(since header calls can get blown if you outputted any text before 
them, and it is easy when working on other peoples code to have:

<?php
some code ?>

<?php
some more code
?>

The blank space between the two blocks will kill your header call.

For the second, is that truly what you wrote?  Your missing the closing 
single quote on the line you posted here.





More information about the talk mailing list