Re: Code for db connection errors
| From: | Jason Wong | Date: | Fri, 16 Aug 2002 02:20:55 +0000 |
| Subject: | Re: Code for db connection errors | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-112895@lists.php.net to get a copy of this message | ||
On Friday 16 August 2002 10:15, Andre Dubuc wrote:
> Suppose, during an attempted connection to a database, an error condition
> occurs, where the connection cannot be made.
>
> <?php
> . . .
> $db = pg_connect("dbname=rap user=postgres") die ("Connection failed -
> please try again.");
> . . . .
> ?>
>
> Is it advisable for such a message to be displayed to the User, or should
> such reporting be sent to a log of some sort.
It's probably not very user friendly to display the raw error. You could
redirect the user to a generic error page saying something like "The site is
down for maintenance" or whatever.
> What code could/should I place in the error message -- for example, how can
> I arrange for an e-mail to be sent to me (if that would be advisable)? How
> would you handle this situation?
Look at error_log().
--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
Do not drink coffee in early A.M. It will keep you awake until noon.
*/