note 56270 deleted from function.mysql-query by mazzanet
| From: | mazzanet@php.net | Date: | Sun, 02 Oct 2005 13:14:21 +0000 |
| Subject: | note 56270 deleted from function.mysql-query by mazzanet | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-96169@lists.php.net to get a copy of this message | ||
Note Submitter: davidgwalker-at-dwalker-dot-co-dot-uk
----
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