php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #38998 wrong default values in constructor
Submitted: 2006-09-29 22:42 UTC Modified: 2009-03-15 15:33 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: camka at email dot ee Assigned: georg (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.1.6 OS: win 2000
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: camka at email dot ee
New email:
PHP Version: OS:

 

 [2006-09-29 22:42 UTC] camka at email dot ee
Description:
------------
If passing NULL parameters in mysqli::__construct, as they are by default, the values are not actually taken from php.ini (or apache conf) file.

Tested with both 5.1.6 and 5.2 latest snapshot.

Reproduce code:
---------------
virtual host conf:
php_admin_value "mysqli.default_host" zorro
php_admin_value "mysqli.default_user" rootf
php_admin_value "mysqli.default_pw" ff

<?
$m = new mysqli(); echo mysqli_connect_error(), "\n";
$m = new mysqli(null); echo mysqli_connect_error(), "\n";
$m = new mysqli(null, null); echo mysqli_connect_error(), "\n";
$m = new mysqli(null, null, null); echo mysqli_connect_error(), "\n";
?>

Expected result:
----------------
Access denied for user 'rootf'@'zorro' (using password: YES) 
Access denied for user 'rootf'@'zorro' (using password: YES)
Access denied for user 'rootf'@'zorro' (using password: YES)
Access denied for user 'rootf'@'zorro' (using password: YES)

Actual result:
--------------
[empty]
Access denied for user 'rootf'@'localhost' (using password: YES) 
Access denied for user 'ODBC'@'localhost' (using password: YES) 
Access denied for user 'ODBC'@'localhost' (using password: NO) 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-02 08:54 UTC] tony2001@php.net
NULL values passed as parameter to mysqli::__construct() have a special meaning, which are described in the docs.
 [2006-10-02 09:04 UTC] camka at email dot ee
This does not describe, why the first case does not give an error at all, even if the host is not reachable or does not exist:

$m = mysqli(); // with no parameters
 [2006-10-02 09:09 UTC] tony2001@php.net
Assigned to the maintainer.
 [2008-01-12 18:15 UTC] hholzgra@php.net
Calling the constructor without any argument is like calling mysqli_init() to create a mysqli object, it does not try to connect at all in this case but waits for an explicit call to mysqli::connect() or mysqli::real_connect() which allows to set mysqli::options() before connecting

Reclassified as documentation bug as the documentation on the mysqli constructor is not clear about this.
 [2009-03-15 15:33 UTC] danielc@php.net
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.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 11:01:28 2025 UTC