#45646 [Opn]: Failed Connect Does Not Return FALSE
| From: | jani@php.net | Date: | Tue, 29 Jul 2008 21:01:45 +0000 |
| Subject: | #45646 [Opn]: Failed Connect Does Not Return FALSE | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-1022@lists.php.net to get a copy of this message | ||
ID: 45646
Updated by: jani@php.net
Reported By: djneoform at gmail dot com
Status: Open
-Bug Type: MySQLi related
+Bug Type: Documentation problem
Operating System: Win2k3 Standard
PHP Version: 5.2.6
New Comment:
The manual page isn't quite clear that this concerns only the
procedural style connect, not the OO way.
Previous Comments:
------------------------------------------------------------------------
[2008-07-28 14:49:21] djneoform at gmail dot com
Description:
------------
When a mysqli connection fails, the returned value is an empty mysqli
object and not a bool(FALSE), this means any tests on the connection
will not work, eg: if ($conn) { ... }
When the documentation: http://ca.php.net/manual/en/mysqli.connect.php
States:
"Return Values
Returns a object which represents the connection to a MySQL Server or
FALSE if the connection failed."
Reproduce code:
---------------
<?php
$connection = new mysqli('localhost', 'badinfo', 'badinfo',
'badinfo');
var_dump($connection);
?>
Expected result:
----------------
bool(FALSE)
Actual result:
--------------
object(mysqli)#1 (0) { }
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=45646&edit=1