Jump to content

Log problems to fine and redirect


son

Recommended Posts

I use a custom error handler, which I include in all pages first thing as:

<?phpfunction my_error_handler($errno, $errstr, $errfile, $errline) {$errLogLine = date("n/j/y H:i:s")." - ".$errfile.":".$errline.$contextENV.": ".$errstr."\n";error_log ($errLogLine, 3, "pathToFile/logfile.log");header ("Location: error.php");exit();}set_error_handler("my_error_handler");?>

If I wanted to do same thing for mysql errors could I replace 'or die ('sorry');', so it also logs and redirects when problems occur?Son

Link to comment
Share on other sites

You can do anything you want when you detect an error.
Would I replace then the 'or die' clause with 'or my_error_handler ()'? How do I set for each db bit that the error handler should take over?Son
Link to comment
Share on other sites

If you're just using the normal mysql functions then you have to change it for every one. If you're using a custom database class that has its own query function then you can just change it there.
Thanks, will have a go....Son
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...