Re: Code for db connection errors
| From: | Pafo | Date: | Fri, 16 Aug 2002 02:22:30 +0000 |
| Subject: | Re: Code for db connection errors | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-112896@lists.php.net to get a copy of this message | ||
why not:
<?php
$error[] = "Connection to the database failed";
....
$db = pg_connect("dbname=rap user=postgres") die (error(0));
function error ($code) {
switch ($code) {
case 0 : reportErrMsg($error[$code]); break;
...
}
}
?>
i think ive would have done something like that...
but im not the greatest expert on php :)
regards
patrick
"Andre Dubuc" <aajdubuc@webhart.net> skrev i meddelandet
news:20020816021557.73BB22004B0@localhost.localdomain...
> 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.
>
> (I'm unclear of what use the message would be to the User, and since the
site
> is not on my server, but on my IP's, I would definetly like to know if a
> failed connection occurs, so that I could investigate the problem)
>
> 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?
>
>
> Any guidance would be greatly appreciated,
> Tia,
> Andre