Below is the function, known as safe_query.php; include it with your query. Place
the next lines
inside your code:
mysql_query($query) or die(sql_failure_handler($query, mysql_error()));
$query = "select * from admin where name = '$name'";<?php
function sql_failure_handler($query, $error) {
$msg = htmlspecialchars(“Failed
Query: {$query}<br>SQL
Error: {$error}”);
error_log($msg, 1,
“Bob@Zoolamoves.com, "From:
sysadmin@zoolamoves.com”);
/* The above line sends the error to
your email AND it come from the 4th parameter.
TO send it to an
file called sql_error_log use this line:
error_log($msg, 3,
“/home/site/logs/sql_error_log”);
Notice that the second parameter is now 3 and there is not a 4th parameter
*/
if (defined(‘debug’)) {
return $msg;
}
return “Requested page is temporarily unavailable, please try again later.”;
}
?>
/* the above few lines return the message to the screen if debug is defined
and puts an error message on the screen for the user */