$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,"");
}
require 'config-pdo.php'; // database connection string
$pdo=$dbo->prepare('Select * from nonexistence_table');
if($pdo->execute()){
echo 'Success<br>';
}else{
$error_msg = "Error Code : ".$pdo->errorCode()."<br>";
$error_msg = $error_msg . "Error Message : ". print_r($pdo->errorInfo());
echo $error_msg;
mail("programmer@sitename.com","error message",$error_msg,"");
}
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.
Ted | 08-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. |