EchoFool Posted May 20, 2009 Share Posted May 20, 2009 Hey, Quick question, is there a way to stop errors from displaying and put them into a mysql INSERT query which inserts into my database for me to deal with in a bug page that i coded myself.... im referring to all kind of php errors/mysql errors... can php be set up to do this or is it not possible (include syntax errors) Just curious, because im aming to make a system that saves bugs automatically for staff to deal with, its more efficient than waiting on users to bug report it. Quote Link to comment https://forums.phpfreaks.com/topic/158851-solved-displayed-errors-sent-to-database/ Share on other sites More sharing options...
PFMaBiSmAd Posted May 20, 2009 Share Posted May 20, 2009 You should probably write database errors to a log file - http://us2.php.net/manual/en/function.error-log.php Because if you are experiencing errors due to problems with your database, you likely won't be able to store the errors in the database, whereas the file system would be available if your web site is functional at all. Quote Link to comment https://forums.phpfreaks.com/topic/158851-solved-displayed-errors-sent-to-database/#findComment-837834 Share on other sites More sharing options...
Masna Posted May 20, 2009 Share Posted May 20, 2009 function store_errors($error_level, $error_message, $error_file, $error_line, $error_context){ $insert = mysql_query("INSERT INTO `table` (`error_level`, `error_message`, `error_file`, `error_line`, `error_context`) VALUES ('$error_level', '".mysql_escape_string($error_message)."', '".mysql_escape_string($error_file)."', '".mysql_escape_string($error_line)."', '".mysql_escape_string($error_context)."')"); } set_error_handler("store_errors"); //this of course implies that you've created a MySQL table called "table" with 5 fields (error_level, error_message, error_file, error_line, error_context) Quote Link to comment https://forums.phpfreaks.com/topic/158851-solved-displayed-errors-sent-to-database/#findComment-837835 Share on other sites More sharing options...
EchoFool Posted May 20, 2009 Author Share Posted May 20, 2009 function store_errors($error_level, $error_message, $error_file, $error_line, $error_context){ $insert = mysql_query("INSERT INTO `table` (`error_level`, `error_message`, `error_file`, `error_line`, `error_context`) VALUES ('$error_level', '".mysql_escape_string($error_message)."', '".mysql_escape_string($error_file)."', '".mysql_escape_string($error_line)."', '".mysql_escape_string($error_context)."')"); } set_error_handler("store_errors"); //this of course implies that you've created a MySQL table called "table" with 5 fields (error_level, error_message, error_file, error_line, error_context) Good point PFMaBiSmAd how do i get database errors to go to a log file? And thanks for the function suggestion... does "store_errors" automatically mean it has those 5 settings in that store_errors name? Quote Link to comment https://forums.phpfreaks.com/topic/158851-solved-displayed-errors-sent-to-database/#findComment-837846 Share on other sites More sharing options...
EchoFool Posted May 20, 2009 Author Share Posted May 20, 2009 Thats odd the function created this error: It is not safe to rely on the system's timezo' at line 2 Quote Link to comment https://forums.phpfreaks.com/topic/158851-solved-displayed-errors-sent-to-database/#findComment-837853 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.