By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,983 Members | 2,035 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,983 IT Pros & Developers. It's quick & easy.

PHP, MySQL and exception handling

P: n/a
I want to find out how I can ensure that if MySql has a burp and can't write
to my DB, I will have a way of capturing the error and show my users
something more pleasing than a system error message.

Is this something that's a part of PHP-MySql combo? I currently use MS
Access, and it sucks ... if there is a DB write error, or the DB gets
locked, then my user sees this glaring error message ... (BTW if you know
how to get by that one, do let me know ... it's an immediate issue for me
.... I appreciate it). I'd rather try to have their data e-mailed to me or
something.

Thanks,
Santosh
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"OneSolution" a écrit le 19/11/2003 :
I want to find out how I can ensure that if MySql has a burp and can't write
to my DB, I will have a way of capturing the error and show my users
something more pleasing than a system error message.


Of course you can, just check the doc http://www.php.net/
use the following functions :
mysql_errno()
mysql_error()
to get the error message.

You can add an "OR DIE()" function after your SQL command like

$db = mysql_connect( $server, $user, $pass ) or die("Can't connect to
DB!");
Jul 17 '05 #2

P: n/a
Cool. So when it "dies", then does that mean the rest of the code can
execute through an error scenario or does it stop running the script?
Basically, I don't want a system error message getting to my user. I want
to have the opportunity to tell my user something other than the actual
technical error message.

Thanks,
Santosh

"Jedi121" <je*********@free.fr.Removethis> wrote in message
news:me********************************@free.fr.Re movethis...
"OneSolution" a écrit le 19/11/2003 :
I want to find out how I can ensure that if MySql has a burp and can't write to my DB, I will have a way of capturing the error and show my users
something more pleasing than a system error message.


Of course you can, just check the doc http://www.php.net/
use the following functions :
mysql_errno()
mysql_error()
to get the error message.

You can add an "OR DIE()" function after your SQL command like

$db = mysql_connect( $server, $user, $pass ) or die("Can't connect to
DB!");

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.