Doc #66290 [Opn->Csd]: (bool)(new Mysqli(...)) is always TRUE !!

From: Date: Fri, 13 Dec 2013 18:11:16 +0000
Subject: Doc #66290 [Opn->Csd]: (bool)(new Mysqli(...)) is always TRUE !!
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-10707@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66290&edit=1 ID: 66290 Updated by: krakjoe@php.net Reported by: ryosuke_i_628 at yahoo dot co dot jp Summary: (bool)(new Mysqli(...)) is always TRUE !! -Status: Open +Status: Closed Type: Documentation Problem Package: Documentation problem PHP Version: Irrelevant -Assigned To: +Assigned To: krakjoe Block user comment: N Private report: N New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2013-12-13 16:32:34] ryosuke_i_628 at yahoo dot co dot jp Description: ------------ --- From manual page: http://www.php.net/mysqli.construct --- (bool)(new Mysqli(...)) is always TRUE. So you can't use this value for judging. You have to use mysqli_connect_errno(). Expected result: ---------------- <?php $link = mysqli_connect('localhost', 'my_user', 'my_password', 'my_db'); if (mysqli_connect_errno()) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); } echo 'Success... ' . mysqli_get_host_info($link) . "\n"; mysqli_close($link); ?> Actual result: -------------- <?php $link = mysqli_connect('localhost', 'my_user', 'my_password', 'my_db'); if (!$link) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); } echo 'Success... ' . mysqli_get_host_info($link) . "\n"; mysqli_close($link); ?> ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=66290&edit=1

« previous php.doc.bugs (#10707) next »