Re: Header - Redirect Command Not Working

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Bastien - Stuart & Daniel

Thanks for your help!


On 3/10/2009 12:16 PM, "Bastien Koert" <phpster@xxxxxxxxx> wrote:

> Are you getting an error? What does 'not working' mean?

No errors the page just stayed on the
header('Location: show.php'); page - never went to: show.php

---

On 3/10/2009 12:17 PM, "Stuart" <stuttle@xxxxxxxxx> wrote:

> Is display_errors on and error_reporting set to at least E_ALL? My guess
> would be your test server has output buffering on but your main server does
> not. Without errors there's no way to be sure.

Not sure Stuart - I will look into this....


----

On 3/10/2009 12:21 PM, "Daniel Brown" <danbrown@xxxxxxx> wrote:

>> It works on my test server w php 5.2.6 but not at the main server w v 5.12
> 
>     Did you already have some output sent to the browser?  That may be
> causing header() not to be able to send the Location header to the
> browser properly.

Yes the page if a combo form / action page

Q: I might have learned something.... Does the: header('Location: xxx.php');
command need to be in the first php block? On some pages when I make multi
php blocks into 1 big one and put the header command inside it - it seems to
work better - is this true?

Q: Also, is it possible that extra whitespace inside the php block can cause
the header command to not work? (I might have that happening also - looking
into it) 


> 
>> Is there a way to get it to go to the other page (even with a different
>> command/function) - or am I doing something wrong?
> 
>     Well, if the above is in fact the case (and yes, different
> versions and installations have been known to respond differently),
> then you can use a browser-based meta refresh, which will work for all
> browsers anyway:
> 
> <?php
> // .... your code....
> header('Location: show.php');
> echo '<meta http-equiv="refresh" content="0;show.php">';
> flush();
> exit(0);
> ?>


I tried refresh Daniel - and it worked great!

I even added a GET var to it - worked also

echo '<meta http-equiv="refresh" content="0;show.php?id='.$_GET[id].'">';

Thanks again folks!


> 
>     This kills three birds with the same stone like so:
> 
>         1.) It tries to use the header() location redirect.
>         2.) It falls back on browser-based redirection.
>         3.) It forces a flush() of the data to the client, regardless
> of minimum size limits.
>         4.) It forces the script to exit with a non-error code of 0.





--
Thanks - RevDave
Cool @ hosting4days . com
[db-lists 09]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux