jasonc Posted April 12, 2006 Share Posted April 12, 2006 i wish to catch any errors that may happen when a query is made to the mysql database.i have it so that an error message pops up when it happens but can i have an email sent to me telling me this too, as the visitor may not let me know.can this be done?thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/7259-email-notify-when-error-querying-database/ Share on other sites More sharing options...
wickning1 Posted April 13, 2006 Share Posted April 13, 2006 That's something you'll have to do on the PHP end.. write a function for it, then you can do something like this:$result = mysql_query(....) or email_me(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/7259-email-notify-when-error-querying-database/#findComment-26448 Share on other sites More sharing options...
fenway Posted April 13, 2006 Share Posted April 13, 2006 That's right -- basically, as long as you can trap the call the generates the error, you can handle it however you see fit (and so you should). Silent errors -- or even worse, errors that the user sees and can do nothing about -- should never exist. I always get annoyed when I see the typical "an error has ocurred.... please contact the webmaster". If they know an error occurs, the webmaster should be contacted automatically! That's how it works on every project I've ever written. Quote Link to comment https://forums.phpfreaks.com/topic/7259-email-notify-when-error-querying-database/#findComment-26464 Share on other sites More sharing options...
jasonc Posted April 13, 2006 Author Share Posted April 13, 2006 Please can you provide information on how you would do this.thank you[!--quoteo(post=364279:date=Apr 13 2006, 05:50 AM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Apr 13 2006, 05:50 AM) [snapback]364279[/snapback][/div][div class=\'quotemain\'][!--quotec--]That's right -- basically, as long as you can trap the call the generates the error, you can handle it however you see fit (and so you should). Silent errors -- or even worse, errors that the user sees and can do nothing about -- should never exist. I always get annoyed when I see the typical "an error has ocurred.... please contact the webmaster". If they know an error occurs, the webmaster should be contacted automatically! That's how it works on every project I've ever written.[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/7259-email-notify-when-error-querying-database/#findComment-26500 Share on other sites More sharing options...
fenway Posted April 13, 2006 Share Posted April 13, 2006 Well, I'm not particularly familiar with PHP's error/exception handling, but at least for DB connections and queries, you can simply call your own custom error handler on any errors instead of calling die(). For other parsing-related errors, I assume that there's a way to catch the DIE signal, much like there is in Perl. Quote Link to comment https://forums.phpfreaks.com/topic/7259-email-notify-when-error-querying-database/#findComment-26725 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.