SQL PHP HTML ASP JavaScript articles and free scripts to download
SQL PHP MySQL Functions

Query Error message posting to E-mail address

In different situations sql query can generate error message and display it along with error number. But most of the time develops is not the user of the script and for a normal user these error message or error number are of no use. The programmer can interpret meaning full reason of the error. So instead of displaying the error message to the visitor this script can post the error message and error number generated out of query to the email address of the programmer. We will use this small php mail script to post the error message to the programmer.

First we will test if there is an error or not by checking mysql_query() function. This function will return true if query is successful and will return false in case of error. So we will use php if else condition to check the status of this mysql_query() function. Here is the small code.

$query = mysql_query("SELECT no_field FROM student");
if(!$query){ // condition to check in case of error only
$error_msg= "Erron No:".mysql_errno(). "<br>";
$error_msg .="Error message = ".mysql_error();
mail("programmer@sitename.com","error message",$error_msg,"");
}


Google+

More on PHP MySQL functions
Ted08-12-2010
What if the error is something other than a mysql error. Like a syntax error or something? Is there an error code or process for that? I have such an error and Dreamweaver does not tell me.
addrrr30-01-2013
What if the error is something other than a mysql error. Like a syntax error or something? Is there an error code or process for that? I have such an error and Dreamweaver does not tell me.
Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked



Join Our Email List
Email:  
For Email Newsletters you can trust

HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer