ID: 45940
Updated by: johan...@php.net
Reported By: talmage dot news at gmail dot com
Status: Closed
Bug Type: MySQLi related
Operating System: Centos 5
PHP Version: 5.2.6
Assigned To: mysql
New Comment:
Fixed in 5.2 CVS, too, now.
Previous Comments:
[2009-01-12 12:56:23] johan...@php.net
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
[2009-01-10 10:23:30] nullhility at gmail dot com
Getting the same error with the following version:
PHP 5.2.4-2ubuntu5.4 with Suhosin-Patch 0.9.6.2
I was attempting to suppress errors so I could control
output/formatting etc. Thought i'd just re-iterate this for version
related purposes.
?php
//a forced username/password mismatch
$dbo = @new mysqli('localhost', 'r00t', 'pass', 'my_db');
var_dump($dbo-connect_error);
var_dump(mysqli_connect_error());
?
output:
Warning: main(): Couldn't fetch mysqli in /home/default/php/mysqli.php
on line 4
NULL
string(63) Access denied for user 'r00t'@'localhost' (using password:
YES)
[2008-12-25 21:17:22] ws at develtheory dot com
Was able to reproduce the error in the same method on php 5.2.8, both
with purposeful incorrect passwords and nonexistent host/port combos.
the object is created, connect_error returns NULL on var_dump, error
log dumps:
Dec 25 15:12:18 dev01 httpd: PHP Warning: dbo::__construct() [a
href='dbo.--construct'dbo.--construct/a]: Couldn't fetch mysqli in
/nfs/beta/www/classes/dbo-new.inc.php on line 88
[2008-12-01 13:39:16] dannyrjohnston at msn dot com
Forget my previous comment. I found some code between the new mysqli
statement in the example I was using which was setting the $dbObj to
false if mysql_connect_error was returning a value.
[2008-12-01 13:17:14] dannyrjohnston at msn dot com
I have duplicated this issue.
According to the manual mysqli::__construct should always return a
object, but the function is returning a false value on error.
I have tried three different possible error conditions and have the
following results:
Bad user/password combo: mysqli_connect_error() returns Access
denied for user 'xxx'@'xxx' (using password: YES), return value is
false.
User does not have access to the db selected:
mysqli_connect_error()returns Access denied for user 'xxx'@'xxx' to
database 'xxx', return value is false.
Bad port number: mysqli_connect_error() returns Can't connect to
MySQL server on 'localhost' (10061), return value is false.
I have not checked any other cases such as bad socked name, but in each
of the above conditions I received a false value not an object.
test code:
?php
$dbObj = new mysqli( localhost, user, pass, db, 3306);
echo dbObj=;
var_dump($dbObj);
?
error result:
dbObj=bool(false)
sucess result:
dbObj==object(mysqli)#1 (0) {
}
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/45940
--
Edit this bug report at http://bugs.php.net/?id=45940edit=1