note 54123 deleted from function.mysql-query by mazzanet

From: Date: Sun, 02 Oct 2005 13:16:02 +0000
Subject: note 54123 deleted from function.mysql-query by mazzanet
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-96171@lists.php.net to get a copy of this message
Note Submitter: ek2 at ek2 dot org ---- Hi! I use a small wrapper-function that adds some error-reporting capabilities to mysql_query(). If you add these, reportError() will be called upon each failed query. By modifying reportError, you may easily add powerful logging capabilities to your script (or just get rid of putting echo mysql_error(); behind each query for debugging purposes ;) ). Using it is fairly easy - just replace each occurence of "mysql_query ($myquery);" with "extendedMysqlQuery ($myquery);". <?php function reportError ( $error, $debugLevel=0 ) { echo "<br>" . $error . "<br>"; } function extendedMysqlQuery ( $query ) { $result = mysql_query ( $query ); if ( $result === false ) { reportError ( "MySQL-Error:\n" . mysql_error() . "\nQuery:\n$query", 0 ) return false; } else return $result; } ?>

« previous php.notes (#96171) next »