|
Posted by Klaus Brune on 09/27/06 03:48
I don't know if this will be more efficient than using a conditional,
but two other avenues, off the top of my head...
1) Turn off error messages, then enable again after your call. Something
like...
$oldErrorReporting = error_reporting(0)
// ... do your stuff ...
error_reporting($oldErrorReporting)
2) Do output buffering before and after your code to grab any unwanted
errors, notification, etc...
ob_start();
$oldErrorReporting = error_reporting(E_ALL);
$oldHtmlErrors = ini_set('html_errors',0);
// ... do your stuff ...
$errorMessages = ob_get_clean();
error_reporting($oldErrorReporting);
ini_set('html_errors',$oldHtmlErrors);
if(trim($errorMessages) == '') {
mail('me@example.com','MySQL Error Report',$errorMessages)
}
Hmmm, this might be worthy of a wiki topic. Plus it might be a little
clearer with syntax highlighting. And I won't have to post multiple
times if I want to expand the whole error trapping idea when I have
time. The ideas are flowing already... dumping to different error log
files based on what routine(s) you're watching for instance. Anyway,
here's the link...
http://www.gunthersoft.com/wiki/ErrorHandlingWithPHP
In article <1159199002.996276.77090@i42g2000cwa.googlegroups.com>,
mcyi2mr3@googlemail.com says...
> Hi all!
>
> How can you get rid of the error that displays if you do a query which
> returns no result and then try and fetch the array, WITHOUT having to
> put the while in another conditional like if ($result != ''), something
> more efficient if possible.
>
> regards
>
> Marc
>
>
Navigation:
[Reply to this message]
|