Jump to content

Archived

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

jasonc

email notify when error querying database

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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());

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.