At 23:42 09.11.2002, Monty said:
>Is there any way to gracefully handle errors that happen after output to the
>screen has begun (the point where header(Location:) doesn't work) without
>using ob_ functions?
>I have a separate PHP page I'd like to display with the error if one happens
>using the error_handler() and trigger_error() functions. But, I can't make
>it work because if the error happens after output starts, I just get an
>error stating header() won't work.
>I'm also not sure of the best way to pass all the error data to the error
>page. Its too much for a $_GET.

One way, as you just have ruled out, would be using the ob_ functions.

However you can redirect the browser using JavaScript, with the drawback
that this will only work with compliant clients and JS not disabled.

Passing data to the error page could be done by using session data, or if
you don't want to use sessions, create a temp file and pass the name and
location to the error page.

Sending the javascript:

if ($we_found_an_error) {
        $url = 'http://' . $_SERVER['SERVER_NAME'] .
        echo '<script language="JavaScript">',
             'document.location.href="', $url, '">',
             'A nasty error has occurred. If you are not redirected ',
             'to the correct page, <a href="',$url,'">click here</a> to',
             'continue (sorry folks)';
// else no error - continue


Hope this helps,

   >O     Ernest E. Vogelsinger
   (\)    ICQ #13394035

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to