View Single Post
Old 09-02-2003, 03:04 PM   #20 (permalink)
bdl
Senior Contributor
 
Join Date: May 2002
Location: vta.ca.usa
Posts: 555
bdl is on a distinguished road
PHP Code:
<?
$dbcnx 
= @mysql_connect("localhost""root""mypasswd");
if (!
$dbcnx)
{
  echo( 
"<P>Unable to connect to the database server at this time.</P>" );  
  exit();
}
?>
Hmm. Correct me if I'm wrong, but in your syntax above, $dbcnx would still 'have value' or 'exist' in the method you use. You supply it with a null value even if the MySQL connection fails.

Your syntax on echo ( " (with the extra spacing) may also be hanging things up, try just using echo " or echo(".

What I usually do is this:
PHP Code:
if (!$dbcnx mysql_connect("server""user""password"))
  die(
"Could not connect to MySQL DB: " mysql_error()); 
That would definitely give you an error if you couldn't connect to the MySQL server, and tell you why (thats the mysql_error() part). You should try removing error suppression (the '@' symbol) when you test a script, make sure you get all the bugs first. Then if it fails later on at least error messages won't get to the user.
bdl is offline   Reply With Quote