I use this script quite frequently now on PHP projects for simple error reports straight to my email account. Your clients are well pleased when you have the bug/error fixed before they report it to you.
All you need to do is copy the following script and paste it into a file and include it into your project.
ie:
< ?php include('error_control.php'); ?>
The page error_control.php contains the script below
< ?php $debug = true; function error_handler($errno, $errstr, $errfile, $errline) { global $debug; // echo a message to the end user echo '<span class="error_message">There has been a major error, now that we know about this error we will fix it!'; $message .= 'File: '. __FILE__ .'<br />'; $message .= 'Line: '. __LINE__ .'<br />'; $message .= '<br />'; switch ($errno) { case E_USER_ERROR: if ($errstr == "(SQL)") { // handling an sql error $message .= "<b>SQL Error</b> [$errno] " . SQLMESSAGE . "<br />"; $message .= "Query : " . SQLQUERY . "<br />"; $message .= "On line " . SQLERRORLINE . " in file " . SQLERRORFILE . " "; $message .= ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />"; $message .= "Aborting...<br />"; } else { $message .= "<b>My ERROR</b> [$errno] $errstr<br />"; $message .= " Fatal error on line $errline in file $errfile"; $message .= ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />"; $message .= "Aborting...<br />"; } break; case E_USER_WARNING: $message .= "<b>My WARNING</b> [$errno] $errstr<br />"; break; case E_USER_NOTICE: $message .= "<b>My NOTICE</b> [$errno] $errstr<br />"; break; default: $message .= "Unknown error type: [$errno] $errstr<br />"; break; } $to = 'name@domain-name.com'; $subject = 'WEBSITE ERROR: Name of project/web-site'; "From: website_error@smg.com.au" . EmailNewLine . "Content-type: text/html; charset=iso-8859-1 "; // if $debug is equal to true then show the full error on the website, when you // make the website live make sure you set $debug equal to false if($debug == true) { } return true; } ?>