Outputting all PHP errors to database not error_log

I don’t think it can be done without building an own error handler, but technically, that is the one global change you’re looking for.

Modified example from the manual:

function myErrorHandler($errno, $errstr, $errfile, $errline)
{
     // you'd have to import or set up the connection here 
     mysql_query("INSERT INTO error_log (number, string, file, line) ".
                 "VALUES .....");         

    /* Don't execute PHP internal error handler */
    return true;
}

then

// set to the user defined error handler
$old_error_handler = set_error_handler("myErrorHandler");

Leave a Comment