son Posted July 10, 2008 Share Posted July 10, 2008 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 More sharing options...
justsomeguy Posted July 10, 2008 Share Posted July 10, 2008 You can do anything you want when you detect an error. Link to comment Share on other sites More sharing options...
son Posted July 11, 2008 Author Share Posted July 11, 2008 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 More sharing options...
justsomeguy Posted July 11, 2008 Share Posted July 11, 2008 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. Link to comment Share on other sites More sharing options...
son Posted July 14, 2008 Author Share Posted July 14, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.