473,386 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

PHP, MySQL and exception handling

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
2 8215
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: adi | last post by:
Dear all, This is more like a theoretical or conceptual question: which is better, using exception or return code for a .NET component? I had created a COM object (using VB6), which uses...
7
by: Noor | last post by:
please tell the technique of centralize exception handling without try catch blocks in c#.
3
by: Master of C++ | last post by:
Hi, I am an absolute newbie to Exception Handling, and I am trying to retrofit exception handling to a LOT of C++ code that I've written earlier. I am just looking for a bare-bones, low-tech...
39
by: Mairhtin O'Feannag | last post by:
Hello, I have a client (customer) who asked the question : "Why would I buy and use UDB, when MySql is free?" I had to say I was stunned. I have no experience with MySql, so I was left sort...
2
by: tom | last post by:
Hi, I am developing a WinForm application and I am looking for a guide on where to place Exception Handling. My application is designed into three tiers UI, Business Objects, and Data Access...
9
by: C# Learner | last post by:
Some time ago, I remember reading a discussion about the strengths and weaknesses of exception handling. One of the weaknesses that was put forward was that exception handling is inefficient (in...
44
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level...
4
by: Ele | last post by:
When Exception handling disabled compiler still spits out "C++ exception handler used." Why is that? Why does it ask for "Specify /EHsc"? Thanks! c:\Program Files\Microsoft Visual Studio...
7
by: Ike | last post by:
Let's say I have a MySQL 4.12 database, opened to the internet on 111.111.111.111 allowing all incoming and outgoing ports. I have a username and password setup, which CAN connect to this database,...
1
by: George2 | last post by:
Hello everyone, Such code segment is used to check whether function call or exception- handling mechanism runs out of memory first (written by Bjarne), void perverted() { try{
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.