RE: [PHP] Handling Errors Gracefully
Well, if you rule out ob_* and javascript, the best you can probably do is to just include() your error page or write a function to display it. You won't be redirected to the page, but it'll show up. ---John Holmes... > -Original Message- > From: Monty [mailto:monty3@;hotmail.com] > Sent: Saturday, November 09, 2002 5:43 PM > To: [EMAIL PROTECTED] > Subject: [PHP] Handling Errors Gracefully > > 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. > > Anyone have any suggestions or links to articles that explain how this can > be done?? Thanks a lot. > > Monty > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Handling Errors Gracefully
imho there are many problems with a handler of this type... since an error could occur anywhere--in the middle of an HTML tag, or within a block of client-side script code--you don't know for sure that the Javascript is going to be interpreted properly by the browser...and therefore it may look messy and/or not work at all. Marco -- php|architect - The magazine for PHP Professionals The first monthly worldwide magazine dedicated to PHP programmers Check us out on the web at http://www.phparch.com On Sat, 2002-11-09 at 18:05, Ernest E Vogelsinger wrote: > Ok, it's late, and my last post for today, but I need to get this right ;-) > > if ($we_found_an_error) { >$url = 'http://' . $_SERVER['SERVER_NAME'] . > '/my_error_handler.php?any_parameters_you_need'; >echo '', > 'document.location.href="', $url, '">', > '', > '', > 'A nasty error has occurred. If you are not redirected ', > 'to the correct page, click here to', > 'continue (sorry folks)', > ''; > exit; > } > // else no error - continue > > ?> > > -- >>O Ernest E. Vogelsinger >(\)ICQ #13394035 > ^ http://www.vogelsinger.at/ > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Handling Errors Gracefully
Ok, it's late, and my last post for today, but I need to get this right ;-) ', 'document.location.href="', $url, '">', '', '', 'A nasty error has occurred. If you are not redirected ', 'to the correct page, click here to', 'continue (sorry folks)', ''; exit; } // else no error - continue ?> -- >O Ernest E. Vogelsinger (\)ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Handling Errors Gracefully
At 23:57 09.11.2002, Ernest E Vogelsinger said: [snip] >if ($we_found_an_error) { >$url = 'http://' . $_SERVER['SERVER_NAME'] . > '/my_error_handler.php?any_parameters_you_need'; >echo '', > 'document.location.href="', $url, '">', > '', > '', > 'A nasty error has occurred. If you are not redirected ', > 'to the correct page, click here to', > 'continue (sorry folks)'; // I FORGOT THIS LINE... exit; >} >// else no error - continue > >?> [snip] -- >O Ernest E. Vogelsinger (\)ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Handling Errors Gracefully
At 23:42 09.11.2002, Monty said: [snip] >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. [snip] 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: ', 'document.location.href="', $url, '">', '', '', 'A nasty error has occurred. If you are not redirected ', 'to the correct page, click here to', 'continue (sorry folks)'; } // else no error - continue ?> Hope this helps, -- >O Ernest E. Vogelsinger (\)ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Handling Errors Gracefully
I think the only way to do it the way you want to do it is through buffering (with the ob_functions or via the php.ini file). Turning off error printing is another possibility--that way you can have the errors logged to a file rather than to the screen. Marco -- php|architect - The magazine for PHP Professionals The first monthly worldwide magazine dedicated to PHP programmers Check us out on the web at http://www.phparch.com On Sat, 2002-11-09 at 17:42, Monty wrote: > 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. > > Anyone have any suggestions or links to articles that explain how this can > be done?? Thanks a lot. > > Monty > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Handling Errors Gracefully
Just turn off display_errors in your php.ini file On Sat, 9 Nov 2002, Monty wrote: > 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. > > Anyone have any suggestions or links to articles that explain how this can > be done?? Thanks a lot. > > Monty > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php