note 63721 rejected from function.mysqli-connect by betz

From: Date: Wed, 29 Mar 2006 15:17:03 +0000
Subject: note 63721 rejected from function.mysqli-connect by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-106949@lists.php.net to get a copy of this message
Note Submitter: odysseus at ozu dot es ---- In object oriented style, why I should use mysqli_connect_errno() to check connection? Like: ... ... $mysqli = new mysqli("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } ... ... Why could'nt I use just: ... ... if (!($mysqli = new mysqli("localhost", "my_user", "my_password", "world"))) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } ... ... Should this return false (not object) if there is error in connection?

« previous php.notes (#106949) next »