note 63721 added to function.mysqli-connect

From: Date: Wed, 29 Mar 2006 09:05:17 +0000
Subject: note 63721 added to function.mysqli-connect
Groups: php.notes 
Request: Send a blank email to php-notes+get-106926@lists.php.net to get a copy of this message
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? ---- Server IP: 130.206.1.5 Probable Submitter: 217.127.1.172 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.mysqli-connect.php Edit -- http://master.php.net/note/edit/63721 Del: integrated -- http://master.php.net/note/delete/63721/integrated Del: useless -- http://master.php.net/note/delete/63721/useless Del: bad code -- http://master.php.net/note/delete/63721/bad+code Del: spam -- http://master.php.net/note/delete/63721/spam Del: non-english -- http://master.php.net/note/delete/63721/non-english Del: in docs -- http://master.php.net/note/delete/63721/in+docs Del: other reasons-- http://master.php.net/note/delete/63721 Reject -- http://master.php.net/note/reject/63721 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#106926) next »