Re: How do I detect if mysql_connect failes?

From: Date: Fri, 20 Apr 2001 03:05:46 +0000
Subject: Re: How do I detect if mysql_connect failes?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-49484@lists.php.net to get a copy of this message
On Fri, 20 Apr 2001 12:19, Marcus Rasmussen wrote: > 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. Try testing the value of mysql_errno() and echo mysql_error accordingly. -- David Robley | WEBMASTER & Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet | http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA

« previous php.general (#49484) next »