Currently I am using the follow script to display a message to the user that an error accrued, the script then emails all the data about the error
<?php
// This script determines how errors are handled.
// Flag variable for site status:
$live = TRUE;
// Error log email address:
$email = ' receiving email account';
// Create the error handler.
function my_error_handler ($e_number, $e_message, $e_file, $e_line, $e_vars) {
global $live, $email;
// Build the error message.
$message = "An error occurred in script '$e_file' on line $e_line: \n<br />$e_message\n<br />";
// Add the date and time.
$message .= "Date/Time: " . date('n-j-Y H:i:s') . "\n<br />";
// Append $e_vars to the $message.
$message .= "<pre>" . print_r ($e_vars, 1) . "</pre>\n<br />";
if ($live) { // Don't show the specific error.
error_log ($message, 1, $email); // Send email.
// Only print an error message if the error isn't a notice.
if ($e_number != E_NOTICE) {
echo '<div id="Error">
<div align="center">A system error occurred. We apologize for the inconvenience. Please try again later.<br />
If you keep getting this error please contact the webmaster of this site by <a href="/contact/contact-webmaster.php">clicking here.</a></div>
</div><br />';
}
} else { // Development (print the error).
echo '<div id="Error">' . $message . '</div><br />';
}
} // End of my_error_handler() definition.
// Use my error handler.
set_error_handler ('my_error_handler');
?>
I want to add to this script that it also enters all the data into MySQL database.
Database specs are:
Table name ErrorLog
fields :
[ErrorLine]
[SCRIPT_URL]
[HTTP_HOST]
[HTTP_USER_AGENT]
[HTTP_ACCEPT]
[HTTP_ACCEPT_LANGUAGE]
[HTTP_ACCEPT_ENCODING]
[HTTP_CONNECTION]
[SERVER_SIGNATURE]
[SERVER_SOFTWARE]
[SERVER_NAME]
[SERVER_ADDR]
[SERVER_PORT]
[REMOTE_ADDR]
[SCRIPT_FILENAME]
[REMOTE_PORT]
[GATEWAY_INTERFACE]
[SERVER_PROTOCOL]
[REQUEST_METHOD]
[QUERY_STRING]
[REQUEST_URI]
[SCRIPT_NAME]
Can any one help is this even possible?