RE: [PHP] Re: PHP with MySQL

From: Date: Fri, 03 May 2002 10:49:08 +0000
Subject: RE: [PHP] Re: PHP with MySQL
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-95859@lists.php.net to get a copy of this message
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() Cheers, .b > -----Original Message----- > From: Jon Haworth [mailto:jhaworth@witanjardine.co.uk] > Sent: 03 May 2002 11:34 > To: 'ben@babelfish.co.uk'; PHP > 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. > > HTH > Jon

« previous php.general (#95859) next »