SQL PHP HTML ASP JavaScript articles and free scripts to download
 
 

Query Error message posting to 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. We will test if there is an error or not by checking mysql_query() function. This function will return true of 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.
Related Tutorial
Printing Error number

Mysql Error Message


$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,"");
}

Discuss this tutorial at forum

List of SQL Tutorials


 
Scripts
PHP
JavaScript
HOME
SQL Tutorial List
SQL (Home)
SQL Commands
AVG
Alter Table
Between
Count
Copy Table
Create Table
Delete
Distinct
Group by
Having
Insert
Inner Join
IN
Left join
Limit
Like
MAX
MIN
Order By
OR AND
Rand
Replace
Rename Table
Select Query
Sum
Union
Update
Where
Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.