Entry
How can I log suppressed error messages to a file?
Sep 17th, 1999 11:51
Richard Lynch, Nathan Wallace,
http://www.php.net/manual/function.error-log.php3
will let you choose to log anything you like to the standard log, or
email them to you, or to a file of your own, or to a special debugging
port if you have compiled PHP with debugging.
The latter is probably not what the average scripter wants: It is more
designed for hardcore debugging of PHP itself, and will generate tons of
output mixed in with your output. The first three, however, are quite
likely to be what you want.
As far as getting the suppresed error message goes, there are two
sources:
http://php.net/manual/feature-error-handling.php3
describes the $php_errormsg variable which will contain non-database
errors, as well as how to filter different classes of PHP errors.
Errors coming from a valid database connection will be returned in
database-specific variables and functions: You're going to have to read
the online manual at
http://php.net/manual/
and find your database package to find out how database error messages
get sent back from the database, through PHP, to you.
It should be noted that a failed connection to a database is reported
through $php_errormsg rather than the database's error system: The
database's error systems generally rely on PHP querying the database for
the error message: If the connection failed, PHP can hardly query the
database for data.
You could even write your own error messaging system, using the name of
the script ($PHP_SELF) or __FILE__ and the line number (__LINE__) and
the date("m/d/Y H:i:s") and any pertinent info you need to the log.