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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to