#45940 [NEW]: MySQLI OO does not populate connect_error property on failed connect
From: talmage dot news at gmail dot com
Operating system: Centos 5
PHP version: 5.2.6
PHP Bug Type: MySQLi related
Bug description: MySQLI OO does not populate connect_error property on failed connect
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 bug report at http://bugs.php.net/?id=45940&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45940&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45940&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45940&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=45940&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=45940&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=45940&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=45940&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=45940&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=45940&r=support
Expected behavior: http://bugs.php.net/fix.php?id=45940&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=45940&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=45940&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=45940&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45940&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=45940&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=45940&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=45940&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=45940&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=45940&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=45940&r=mysqlcfg
Thread (13 messages)
- talmage dot news at gmail dot com
- jani@php.net#45940 [Opn->Fbk]: MySQLI OO does not populate connect_error property on failed connect
- talmage dot news at gmail dot com#45940 [Com]: MySQLI OO does not populate connect_error property on failed connect
- johannes@php.net#45940 [Fbk->Asn]: MySQLI OO does not populate connect_error property on failed connect
- mudroeb at gmail dot com#45940 [Com]: MySQLI OO does not populate connect_error property on failed connect
- valentin71 at gmail dot com#45940 [Com]: MySQLI OO does not populate connect_error property on failed connect
- dannyrjohnston at msn dot com#45940 [Com]: MySQLI OO does not populate connect_error property on failed connect
- dannyrjohnston at msn dot com#45940 [Com]: MySQLI OO does not populate connect_error property on failed connect
- ws at develtheory dot com#45940 [Com]: MySQLI OO does not populate connect_error property on failed connect
- nullhility at gmail dot com#45940 [Com]: MySQLI OO does not populate connect_error property on failed connect
- johannes@php.net#45940 [Asn->Csd]: MySQLI OO does not populate connect_error property on failed connect
- johannes@php.net#45940 [Csd]: MySQLI OO does not populate connect_error property on failed connect
- danielc@php.net#45940 [Csd]: MySQLI OO does not populate connect_error property on failed connect