note 56270 added to function.mysql-query

From: Date: Mon, 29 Aug 2005 09:43:28 +0000
Subject: note 56270 added to function.mysql-query
Groups: php.notes 
Request: Send a blank email to php-notes+get-94332@lists.php.net to get a copy of this message
This weekend I a bad experience with a corrupt table, luckily I was automatically notified by a function I had added to the most import PHP scripts on my site. This saved me hours of diagnosis time and possible downtime (I could well of been unaware of the error for days). Its quite simple and can be added in just a few minutes: function reportMySQLError($email, $MySQLError, $TheQuery) { mail($email, "WARNING: Error running one of the MySQL queries on site!.", "The SQL Error was: $TheSQLError The query was: $TheQuery", "From: $email\nReply-To: $email"); } ... THEN IN LATER in your code: ... $result = mysql_query($the_query); if (!$result) reportMySQLError($email, mysql_error(), $the_query); Full details here: http://dwalker.co.uk/forum/viewtopic.php?p=1413 I wish you all prosperity in health and wealth. Dave ---- Manual Page -- http://www.php.net/manual/en/function.mysql-query.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+56270 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56270&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56270&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56270&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56270&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56270&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56270&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+56270&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#94332) next »