Jump to content

Clear output to show error page


techpro

Recommended Posts

I'm running a PHP/MySQL script on my server. Sometimes, presumably due to some transient problem with the MySQL server, the script displays warnings like:

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/blah_blah/file.php on line xx

 

on the page. It's not a script error, because the same page can display perfectly a couple of minutes later.

 

I wanted to have the script display a friendly page saying there is a temporary error, please come back later, when this occurs. With the help of this article I have learned how to trap PHP errors and display my own output. But the output still appears after whatever HTML has already been generated by the script.

 

Is there a way to get the browser to clear everything that has been output so my error message always starts on a clean page? Rewriting the script so that nothing is printed until the end would be way too complicated.

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/57391-clear-output-to-show-error-page/
Share on other sites

Thanks. I didn't write the script. I'm trying to find a solution that requires minimum modification to the existing code, preferably just adding an include line at the top for the error handler. So I can't do anything about what's been output to the browser by the time an error occurs.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.