On Wednesday 22 January 2003 19:11, Andy Clarke wrote:
> Is there a way to get a database query to fail gracefully, so that rather
> than calling Die(), it can work around the problem? In other words, to do
> something like:
>
> if (mssql_connect($sDBhostname,$sDBusername,$sDBpassword)) {
> // connection ok - work with it
> } else {
> // database down - work around it
> }
> // continue with rest of page
>
> Rather than using the following, which causes the page to quit in mid flow:
>
> mssql_connect($sDBhostname,$sDBusername,$sDBpassword) or die("DATABASE
> FAILED TO RESPOND.");
Obviously, quite simply, don't use die(). Instead call a function which can
handle it:
It really depends on what your needs are and what the page does. The most
simple case is print a message informing the user that "the database is down
please try again later" (or words to that effect). At the same time you would
log this failure (to a log file) and/or email someone responsible who can
deal with it.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
Traveling through hyperspace isn't like dusting crops, boy.
-- Han Solo
*/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php