This tutorials is meat to show you how you can show friendly errors to users nicely....
1.we creat a function
in this script U will have to change the email at the $to variable,..so this is how U will use the script
so all db errors will be emailed to U and the errors too will be hidden
1.we creat a function
PHP Code:
function c(){
$error_type=mysql_error();
$site_url=$_SERVER['HTTP_HOST'];
$site_url=str_replace("http://","",$site_url);
$page_name=$_SERVER['REQUEST_URI'];
$time=time();
$error_time=date('d-F-Y. h:m:sA',$time);
$from="error_messenger@$site_url";
$to="your_email;
$subject="An error at $site_url";
$error_msg="Hi Admin,A database error ($error_type) occured on the page http://$site_url$page_name on the $error_time.<br>";
mail($to,$error_msg,$subject,$from);
exit("Database under maintenance ,please try again later.");
}
PHP Code:
$query=mysql_query("SELECT * FROM tablename;")or die(mysql_error_msg());