Re: redirect with header() after headers sent
| From: | scottrus at ipass dot net | Date: | Wed, 30 Aug 2000 02:22:39 +0000 |
| Subject: | Re: redirect with header() after headers sent | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-14382@lists.php.net to get a copy of this message | ||
On Wed, Aug 30, 2000 at 03:23:16PM +1100, Simon Edwards wrote:
> Sorry if I seem to be questioning the question, but why don't you work
> on your database or SQL calls so that the SQL *doesn't* fail. I mean,
> what ever way you do it and SQL isn't friendly no matter what way you
> deliver the news to the user...
*laugh* That is my goal of course. Still, I've learned that programing
for everything in the real world is not possible. You can catch 90% of
the known error conditions but eventaully someone will do something
unexpected. One example might be where the sql server dies and the
connection fails.
> Anyway, back in the Real World. First you probably want to read the PHP
> config docs. I'm should there are ways of controlling where error
> messages go (You should be able to stop PHP from putting messages in
> your page). You could also store up everything after the prepend stuff
> into a string, then output the string once you have finished with SQL.
> This way if it fails you can detect that and output an error message
> instead of the page body (or use include() to directly include the
> errormsg.html file). THis way would not require a redirect.
>
> One final hack method would be to open javascript to immediately kick
> the user onto the error message page...
> Simon Edwards
Goods suggestions. I just downloaded the PHP 4.0.2 archive and have been looking
through the docs and code for just these reasons. Yes, I'll disable error reporting
to the screen on my production site and I've created a Mysql class to provide
consistant error checking and usage through out the site.
I want to avoid JS for the obvious reason of not every browser supports it and several
people run with JS disabled.
Right now since it looks like there is no way to end the page sent and then redirect
to another location I will have to arrange my code to do all php scripts before I
send the header that's included with auto_prepend_file. I was hoping to find a better
solution that would allow me to more freely mix the php code in with the HTML even after
headers were sent.
I've been doing some reading up on the buffer functions and noticed the output_buffering
directive in the php.ini file but am not sure I want to take the speed hit. Can anyone
comment on how much the really slows down the php layer and where it really matters?
--
Scott