|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35868 wrong handling of mysql connections hashing
Submitted: 2006-01-01 22:34 UTC Modified: 2006-01-01 23:11 UTC
From: giovanni at giacobbi dot net Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 4.4.1 OS: *
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: giovanni at giacobbi dot net
New email:
PHP Version: OS:


 [2006-01-01 22:34 UTC] giovanni at giacobbi dot net
The code for reproducing is self-explanatory. Anyway, the problem appears when handling multiple connections to the same database with the same login and passwords.

I'm testing a script that handles connections to multiple MySQL databases, and for testing purposes I need to operate with two separated local database. However, the connection is only distinguished by the database name, while you use only host, user, and password for hashing the single connection.

This results in a collision when opening the second connection, and makes it impossible to recover the previous one using mysql_connect()'s existing link functionality, even if the connection itself is still open.

Reproduce code:
/* create primary connection */
$r1 = mysql_connect("localhost", "root", "*****", TRUE);
mysql_select_db("dbname1", $r1) or die(mysql_error());
/* create auxiliary connection */
$r2 = mysql_connect("localhost", "root", "*****", TRUE);
mysql_select_db("dbname2", $r2) or die(mysql_error());
/* get rid of auxiliary connection when done */

/* fetch back the previous connection as default! */
$r3 = mysql_connect("localhost", "root", "******");


Expected result:
resource(4) of type (mysql link)
resource(5) of type (mysql link)
resource(4) of type (mysql link)

Actual result:
resource(4) of type (mysql link)
resource(5) of type (mysql link)
resource(6) of type (mysql link)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-01 23:11 UTC]
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Feb 21 02:01:28 2024 UTC