ID: 45940
Updated by: jani@php.net
Reported By: talmage dot news at gmail dot com
-Status: Open
+Status: Feedback
Bug Type: MySQLi related
Operating System: Centos 5
PHP Version: 5.2.6
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows (zip):
http://snaps.php.net/win32/php5.2-win32-latest.zip
For Windows (installer):
http://snaps.php.net/win32/php5.2-win32-installer-latest.msi
Previous Comments:
------------------------------------------------------------------------
[2008-08-28 05:26:07] talmage dot news at gmail dot com
Description:
------------
The documentation at:
http://us.php.net/manual/en/mysqli.connect.php
Provides an example for the OO method of constructing a MySQLI instance
and checking for error.
However, when testing this example and forcing an error the output is
not as the documentation describes (which as documented is the way I
would expect the OO library to behave.)
I first noticed this behavior on a PHP 5.2.3 install on my Centos
server. I then tried the same thing on a Debian box on 5.2.3 and
received the same unexpected behavior.
I then downloaded and compiled PHP 5.2.6 on my Centos box and still
received the unexpected behavior.
Reproduce code:
---------------
<?php
/* Force an error -> 3307 is not where mysql is listening */
$mysqli = new mysqli("127.0.0.1:3307", "my_user", "my_password",
"world");
/* Check for error: This should return true and enter the if block */
if ($mysqli->connect_error) {
printf("Connect failed: %s\n", $mysqli->connect_error);
exit();
}
printf("Host information: %s\n", $mysqli->host_info);
/* close connection */
$mysqli->close();
?>
Expected result:
----------------
Connect failed: Unknown MySQL server host '127.0.0.1:3307'
Actual result:
--------------
Warning: mysqli::mysqli(): (HY000/2005): Unknown MySQL server host
'127.0.0.1:3307' (3) in /srv/php/projects/test/src/test.php on line 4
Warning: main(): Couldn't fetch mysqli in
/srv/php/projects/test/src/test.php on line 7
Warning: main(): Couldn't fetch mysqli in
/srv/php/projects/test/src/test.php on line 12
Host information:
Warning: mysqli::close(): Couldn't fetch mysqli in
/srv/php/projects/test/src/test.php on line 15
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=45940&edit=1