RE: [PHP] Re: PHP with MySQL

From: Date: Fri, 03 May 2002 10:33:57 +0000
Subject: RE: [PHP] Re: PHP with MySQL
Groups: php.general 
Request: Send a blank email to php-general+get-95856@lists.php.net to get a copy of this message
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 (#95856) next »