note 98535 added to mysqli.query

From: Date: Mon, 21 Jun 2010 23:11:34 +0000
Subject: note 98535 added to mysqli.query
Groups: php.notes 
Request: Send a blank email to php-notes+get-170354@lists.php.net to get a copy of this message
To add to what Jon (jcwebb) said below, I also like to save the query itself. But I put it into 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: 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: $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 ---- Server IP: 69.147.83.197 Probable Submitter: 173.55.116.58 ---- Manual Page -- http://www.php.net/manual/en/mysqli.query.php Edit -- https://master.php.net/note/edit/98535 Del: integrated -- https://master.php.net/note/delete/98535/integrated Del: useless -- https://master.php.net/note/delete/98535/useless Del: bad code -- https://master.php.net/note/delete/98535/bad+code Del: spam -- https://master.php.net/note/delete/98535/spam Del: non-english -- https://master.php.net/note/delete/98535/non-english Del: in docs -- https://master.php.net/note/delete/98535/in+docs Del: other reasons-- https://master.php.net/note/delete/98535 Reject -- https://master.php.net/note/reject/98535 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#170354) next »