How do I detect if mysql_connect failes?

From: Date: Fri, 20 Apr 2001 02:49:27 +0000
Subject: How do I detect if mysql_connect failes?
Groups: php.general 
Request: Send a blank email to php-general+get-49483@lists.php.net to get a copy of this message
Hello. My question is: How do I detect if mysql_connect() failed when I'm surpressing the error message with @ like $linkid = @mysql_connect("host","user","pass"); And how do I, if it failes, get the error message? The manuel says that it: [quote]Returns a positive MySQL link identifier on success, or an error message on failure.[unquote] In my mind I should be able to detect if it returns an errormessage like this: if(!$linkid) $error = mysql_error(); or: if(!is_int($linkid)) $error = mysql_error(); Noone of theese 2 types works :-(. I'm using is_int() because the manuel says that mysql_connect() returns an int. (How can it then return an error message? I thought that an error message would be some kind if string :-).) Here comes another problem, when an error occours I should be able to see the message with mysql_error() (since the linkid not contains an error message.) Marcus R.

« previous php.general (#49483) next »