I like to save the query itself in a log file, so that I don't have to worry about whether the site is live.
For example, I might have a global function:
<?php
function UpdateLog ( $string , $logfile ) {
$fh = fopen ( $logfile , 'a' );
$fwrite ( $fh , strftime ('%F %T %z')." ".$string."\n";
fclose ( $fh );
}
?>
Then in my mysql function error trapper, something like this:
<?php
$error_msg = "Database error in [page].php / ";
$error_msg .= mysqli_error ( $link )." / ";
$error_msg .= $query;
UpdateLog ( $error_msg , DB_ERROR_LOG_FILE );
?>
I also include the remote IP, user agent, etc., but I left it out of these code samples. And have it e-mail me when an error is caught, too.
Jeff