I am writing an include error reporting file so that when these is and errors it will email me the errors
I have worked out however to get the script to email me when theres an error but i want it to tell me what the error is here is my script.
the reason for the script is that a friend has asked me to build him a web site and from his brief he need a complicated content management system with the capability of article writing and and a photo gallery. i am developing this system using php mysql and JavaScript. so as i would like to develop the system further in the future i felt this script would enable me to iron out the errors while the site is running.
[php]<?php
// Our custom error handler
function nettuts_error_handler($number, $message, $file, $line, $vars)
{
$email = "
An error ($number) occurred on line
$line and in the file: $file.
$message
";$email .= "<pre>" . print_r($vars, 1) . "</pre>";
$headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Email the error to someone...
error_log($email, 1, '[email protected]', $headers);
// The code below ensures that we only "die" if the error was more than
// just a NOTICE.
if ( ($number !== E_NOTICE) && ($number < 2048) ) {
die("There was an error. Please try again later.");
}
}
// custom function to handle errors.
set_error_handler(‘nettuts_error_handler’);
// Trigger an error… (var doesn’t exist)
echo $somevarthatdoesnotexist;
?php>[/php]