|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #60849 Too many open links not reported correctly
Submitted: 2012-01-23 12:25 UTC Modified: 2021-07-19 14:34 UTC
Avg. Score:4.3 ± 0.9
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:2 (100.0%)
From: haavard dot pedersen at gmail dot com Assigned:
Status: Open Package: MySQLi related
PHP Version: 5.3.9 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: haavard dot pedersen at gmail dot com
New email:
PHP Version: OS:


 [2012-01-23 12:25 UTC] haavard dot pedersen at gmail dot com
The "Too many links" error condition does not provide any error code. The only way 
you can get a description of the error is via the warning output. Run test script 
with mysqli.max_connections = 1 to see the problem. This even breaks the 
documentations example for mysqli_real_connect().

Test script:
$link1 = mysqli_init();
$m_rc1 = mysqli_real_connect($link1, 'localhost', 'dbuser', 'dbpassword', 'testdb', 8889);

echo "--- Opening second link ---\n";
$link2 = mysqli_init();
echo "mysqli_init() result : ".var_export($link2, TRUE)."\n";

echo "--- Opening second connection ---\n";
$m_rc2 = mysqli_real_connect($link2, 'localhost', 'dbuser', 'dbpassword', 'testdb', 8889);
echo "mysqli_real_connect() result : ".var_export($m_rc2, TRUE)."\n";
echo "Error number: ".var_export(mysqli_connect_errno($link2), TRUE)."\n";

Expected result:
An error number returned on the last line.

Actual result:
Error number is 0, possibly indicating success.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-05-02 13:59 UTC]
-Type: Bug +Type: Feature/Change Request
 [2012-05-02 13:59 UTC]
This is a bit on the API design/feature request side.

mysqli.max_connections is a PHP setting. It is something enforced by the API. Because it does not come from the server side, the server logic does not set an error. There is no error on the line. Thus, the wrapped C API call, mysql_connect_errno() does not return one.

Error: 1040 SQLSTATE: 08004 (ER_CON_COUNT_ERROR), Message: Too many connections  must not be used to hint that mysqli.max_links has been exceeded. 1040 is a server error code.  One needs a client error code, if at all. For example, Error: 2000 (CR_UNKNOWN_ERROR) Message: Unknown MySQL error could be used together with message pointing to the mysqli configuration.

I say "if at all" because one also has to ask about the semantics of mysqli_connect_errno().
 [2021-07-19 14:34 UTC]
-Type: Feature/Change Request +Type: Documentation Problem
 [2021-07-19 14:34 UTC]
> mysqli.max_connections is a PHP setting.

No; it's called mysqli.max_links.

> The only way you can get a description of the error is via the
> warning output.

No; the error info is available via error_get_last().

Changing to doc problem.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 22 05:01:29 2024 UTC