"")
{
echo "
Sorry, there has been an unexpected database error. The webmaster has been informed of this error.
";
// Error number
$error_message = "
Error Number: | " . @mysql_errno() . " |
";
// Error Description
$error_message .= "Error Description: | " . @mysql_error() . " |
";
// Error Date / Time
$error_message .= "Error Time: | " . date("H:m:s, jS F, Y") . " |
";
// Client
$error_message .= "Client: | " . $client . " |
";
// Script
$error_message .= "Script: | " . $_SERVER["SCRIPT_NAME"] . " |
";
// Line Number
$error_message .= "Line: | " . $line . " |
";
// SQL
$error_message .= "Query: | " . $sql . " |
";
$error_message .= "Processes: | ";
$result = @mysql_list_processes();
while ($row = @mysql_fetch_assoc($result))
{
$error_message .= $row["Id"] . " " . $row["Command"] . " " . $row["Time"] . " ";
}
@mysql_free_result($result);
$error_message .= " |
";
$headers = "From: \"MySQL Debug\" <" . $email . ">\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
// comment the following line if you don't want to get email notifications of MySQL errors
mail($email, "[MySQL Error] ". $client, $error_message, $headers);
// comment the following line if you don't want to display the MySQL errors to the user
echo $error_message;
die();
}
// if you add ?debug=1 to the end of the path this will always show the query and the number of rows it returns
if ($_GET["debug"]=="1")
{
echo "".$sql."
" . $total . " rows found.
";
}
return $result;
}
?>