Re: Error notification and pretty error page
| From: | Jimmy | Date: | Mon, 21 Jan 2002 16:38:34 +0000 |
| Subject: | Re: Error notification and pretty error page | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-81388@lists.php.net to get a copy of this message | ||
Hi Dan,
> How can i include error notification, like if an MySQL error occurs,
> to notify me of the offending page and what the error was, while
> having the page die quietly or nicely, like an message saying that
> the webmaster will be notified please continue?
you can make a generic function to be called when such error occured.
the fucntion will print a nice/default error msg to user and you can
log detail information regarding the error into logfile or DB,
or even send out a notification email to you.
function fatal_error($msg, $file, $line) {
//$msg : the to be logged
//$file: name of file which trigger the error
//$line: line number which trigger the error
}
the usage:
include('<lib which contain fatal_error()>');
@mysql_query or fatal_error (mysql_error(), __FILE__, __LINE__);
__FILE__ and __LINE__ are php predefined constant to indicate current
file and line number which is being parsed/executed.
you always have to pass this __FILE__ and __LINE__ because PHP dont
have the ability to "backtrack" from which file/line a function is
called :(
and dont forget to add "@" sign in front of the PHP's function,
to surpress the error msg generated by PHP.
--
Jimmy
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There is no greater waste as a waste of time