John, presumably I can leave the error reporting on - but pipe it into a
file if i wanted, rather than displaying on screen, and then redirect the
user to another page?

Not asking for code sample here, just whether I can do it or not :)

/me goes to look up mysql_error()



> -----Original Message-----
> From: Jon Haworth [mailto:[EMAIL PROTECTED]]
> Sent: 03 May 2002 11:34
> Subject: RE: [PHP] Re: PHP with MySQL
> Hi .ben,
> > Just out of interest, what's the standard/best/tried
> > &tested method for handling errors in relation to
> > connecting to DB's?  i.e. how to check that the
> > connection was a success, and if not then display why.
> Something like...
> $dbh = mysql_connect ("foo", "bar", "baz")
>   or die (mysql_error ());
> has always worked well for me. When it comes to queries I
> generally tack the
> SQL on the end of the error, like this:
> $q = mysql_query ($sql, $dbh)
>   or die (mysql_error (). "<br><b>". $sql. "</b>");
> Obviously it's a good idea to turn this error reporting off on a
> production
> site, otherwise you risk exposing details of your database structure.
> Jon

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to