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
[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
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
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
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: ?php if ($we_found_an_error) { $url = 'http://' . $_SERVER['SERVER_NAME'] . '/my_error_handler.php?any_parameters_you_need'; echo 'script language=JavaScript', 'document.location.href=', $url, '', '/script', 'hr', '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 ^ 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] ?php if ($we_found_an_error) { $url = 'http://' . $_SERVER['SERVER_NAME'] . '/my_error_handler.php?any_parameters_you_need'; echo 'script language=JavaScript', 'document.location.href=', $url, '', '/script', 'hr', 'A nasty error has occurred. If you are not redirected ', 'to the correct page, a href=',$url,'click here/a 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
Ok, it's late, and my last post for today, but I need to get this right ;-) ?php if ($we_found_an_error) { $url = 'http://' . $_SERVER['SERVER_NAME'] . '/my_error_handler.php?any_parameters_you_need'; echo 'script language=JavaScript', 'document.location.href=', $url, '', '/script', 'hr', 'A nasty error has occurred. If you are not redirected ', 'to the correct page, a href=',$url,'click here/a to', 'continue (sorry folks)', '/script/body/html'; 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
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 ;-) ?php if ($we_found_an_error) { $url = 'http://' . $_SERVER['SERVER_NAME'] . '/my_error_handler.php?any_parameters_you_need'; echo 'script language=JavaScript', 'document.location.href=', $url, '', '/script', 'hr', 'A nasty error has occurred. If you are not redirected ', 'to the correct page, a href=',$url,'click here/a to', 'continue (sorry folks)', '/script/body/html'; 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
Original message From: Joseph Bannon [EMAIL PROTECTED] Date: Wed, Sep 26, 2001 at 11:09:39AM -0500 Message-ID: [EMAIL PROTECTED] Subject: [PHP] handling errors How do I turn off the error messages that appear at the top of the page? I have this function below that if an image is not there for $url, it give a warning. $size = GetImageSize($url); Example error message below... Warning: getimagesize: Unable to open 'http://www.yahoo.com' for reading. line 28 Joseph /Original message Reply Ofcourse it might just be a strange idea stuck in my head for some reason, but you know what helps? Writing code that doesn't produce any errors or warnings. Supressing warnings by just not showing them doesn't really make your code very reliable does it?! /Reply -- * RzE: -- -- Renze Munnik -- DataLink BV -- -- E: [EMAIL PROTECTED] -- W: +31 23 5326162 -- F: +31 23 5322144 -- M: +31 6 21811143 -- -- Stationsplein 82 -- 2011 LM HAARLEM -- Netherlands -- -- http://www.datalink.nl -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] handling errors
Placing an @ symbol before the function name will suppress any errors. @GetImageSize() At 09:09 AM 9/27/2001 +0200, * RzE: wrote: Original message From: Joseph Bannon [EMAIL PROTECTED] Date: Wed, Sep 26, 2001 at 11:09:39AM -0500 Message-ID: [EMAIL PROTECTED] Subject: [PHP] handling errors How do I turn off the error messages that appear at the top of the page? I have this function below that if an image is not there for $url, it give a warning. $size = GetImageSize($url); Example error message below... Warning: getimagesize: Unable to open 'http://www.yahoo.com' for reading. line 28 Joseph /Original message Reply Ofcourse it might just be a strange idea stuck in my head for some reason, but you know what helps? Writing code that doesn't produce any errors or warnings. Supressing warnings by just not showing them doesn't really make your code very reliable does it?! /Reply -- * RzE: -- -- Renze Munnik -- DataLink BV -- -- E: [EMAIL PROTECTED] -- W: +31 23 5326162 -- F: +31 23 5322144 -- M: +31 6 21811143 -- -- Stationsplein 82 -- 2011 LM HAARLEM -- Netherlands -- -- http://www.datalink.nl -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] handling errors
Original message From: Jason G. [EMAIL PROTECTED] Date: Thu, Sep 27, 2001 at 03:25:16AM -0400 Message-ID: [EMAIL PROTECTED] Subject: Re: [PHP] handling errors Placing an @ symbol before the function name will suppress any errors. @GetImageSize() /Original message Reply Yep, I know it does. Yet, it's still no good way of handling your errors/warnings. Unless you made some real intensive errorchecking yourself, you should not use that @-construction or lower the errorreportinglevel. Reporting should be as high as possible (E_ALL). And yes, indeed, it might then just be that you get a lot of warnings (and/or errors). Then you have to fix your code, not start using @ in order to supress them. Errors and warnings are not reported without a reason you know. Even if your code works, when there are warnings it can still happen that in some situation the code will crash. /Reply -- * RzE: -- -- Renze Munnik -- DataLink BV -- -- E: [EMAIL PROTECTED] -- W: +31 23 5326162 -- F: +31 23 5322144 -- M: +31 6 21811143 -- -- Stationsplein 82 -- 2011 LM HAARLEM -- Netherlands -- -- http://www.datalink.nl -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] handling errors
You are completely right. Do intensive error checking. In thousands and thousands of lines of code, I think i only used @ in 3 places - in the functions that connect to the database - I have more robust error checking in place. -Jason Garber deltacron.com At 09:26 AM 9/27/2001 +0200, * RzE: wrote: Original message From: Jason G. [EMAIL PROTECTED] Date: Thu, Sep 27, 2001 at 03:25:16AM -0400 Message-ID: [EMAIL PROTECTED] Subject: Re: [PHP] handling errors Placing an @ symbol before the function name will suppress any errors. @GetImageSize() /Original message Reply Yep, I know it does. Yet, it's still no good way of handling your errors/warnings. Unless you made some real intensive errorchecking yourself, you should not use that @-construction or lower the errorreportinglevel. Reporting should be as high as possible (E_ALL). And yes, indeed, it might then just be that you get a lot of warnings (and/or errors). Then you have to fix your code, not start using @ in order to supress them. Errors and warnings are not reported without a reason you know. Even if your code works, when there are warnings it can still happen that in some situation the code will crash. /Reply -- * RzE: -- -- Renze Munnik -- DataLink BV -- -- E: [EMAIL PROTECTED] -- W: +31 23 5326162 -- F: +31 23 5322144 -- M: +31 6 21811143 -- -- Stationsplein 82 -- 2011 LM HAARLEM -- Netherlands -- -- http://www.datalink.nl -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] handling errors
On Thursday 27 September 2001 09:09, * RzE: wrote: How do I turn off the error messages that appear at the top of the page? I have this function below that if an image is not there for $url, it give a warning. $size = GetImageSize($url); Example error message below... Warning: getimagesize: Unable to open 'http://www.yahoo.com' for reading. line 28 Joseph /Original message Reply Ofcourse it might just be a strange idea stuck in my head for some reason, but you know what helps? Writing code that doesn't produce any errors or warnings. Supressing warnings by just not showing them doesn't really make your code very reliable does it?! Right in principle. But there are cases (common ones), like the one shown above, where errors are unavoidable and normal. For these cases the @ operator is the right thing. Generally you're right though - error reporting should be set to E_ALL and reasons of avoidable errors/warnings should be eliminated. -- Christian Reiniger LGDC Webmaster (http://lgdc.sunsite.dk/) REALITY.SYS corrupted ... reboot Universe [Y,n]? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] handling errors
Right in principle. But there are cases (common ones), like the one shown above, where errors are unavoidable and normal. For these cases the @ operator is the right thing. Generally you're right though - error reporting should be set to E_ALL and reasons of avoidable errors/warnings should be eliminated. Correct me if I'm wrong, but I saw some posts coming along on this list yesterday (I think) telling that getImageSize can't handle URL's. So... in that case... Don't use @, but check the syntax of the variable you want to pass as parameter for getImageSize. But you're right about the *very* few cases in which it is unavoidable. Though, this isn't one of 'm. -- * RzE: -- -- Renze Munnik -- DataLink BV -- -- E: [EMAIL PROTECTED] -- W: +31 23 5326162 -- F: +31 23 5322144 -- M: +31 6 21811143 -- -- Stationsplein 82 -- 2011 LM HAARLEM -- Netherlands -- -- http://www.datalink.nl -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] handling errors
On Thursday 27 September 2001 12:00, * RzE: wrote: Right in principle. But there are cases (common ones), like the one shown above, where errors are unavoidable and normal. For these cases the @ operator is the right thing. Generally you're right though - error reporting should be set to E_ALL and reasons of avoidable errors/warnings should be eliminated. Correct me if I'm wrong, but I saw some posts coming along on this list yesterday (I think) telling that getImageSize can't handle URL's. So... in that case... Don't use @, but check the syntax of the variable you want to pass as parameter for getImageSize. According to my docs (08 Sep 2001) it can. And http://php.net/getimagesize says the same.. -- Christian Reiniger LGDC Webmaster (http://lgdc.sunsite.dk/) REALITY.SYS corrupted ... reboot Universe [Y,n]? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] handling errors
According to my docs (08 Sep 2001) it can. And http://php.net/getimagesize says the same.. Okay! I never use the function. Yesterday that was a conversation on this list in which they/he/she said it couldn't. But indeed if it can there would be a reason to use @. ... I've now made some test-page, and indeed it works like a charm; getimagesize(URL). So now I don't understand what they were talking about. Anyway... So a @ is indeed in place _for_this_one_. -- * RzE: -- -- Renze Munnik -- DataLink BV -- -- E: [EMAIL PROTECTED] -- W: +31 23 5326162 -- F: +31 23 5322144 -- M: +31 6 21811143 -- -- Stationsplein 82 -- 2011 LM HAARLEM -- Netherlands -- -- http://www.datalink.nl -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] handling errors
How do I turn off the error messages that appear at the top of the page? I have this function below that if an image is not there for $url, it give a warning. $size = GetImageSize($url); Example error message below... Warning: getimagesize: Unable to open 'http://www.yahoo.com' for reading. line 28 Joseph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] handling errors
How do I turn off the error messages that appear at the top of the page? I have this function below that if an image is not there for $url, it give a warning. $size = GetImageSize($url); Example error message below... Warning: getimagesize: Unable to open 'http://www.yahoo.com' for reading. line 28 This should do it: $size = @GetImageSize($url); The @ symbol suppresses errors. Chris