#42392 [Opn->Bgs]: Multiple Connections to the same Server and Login Override Previous Connections

From: Date: Thu, 23 Aug 2007 09:10:38 +0000
Subject: #42392 [Opn->Bgs]: Multiple Connections to the same Server and Login Override Previous Connections
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-116527@lists.php.net to get a copy of this message
ID: 42392 Updated by: jani@php.net Reported By: memso at memso dot net -Status: Open +Status: Bogus Bug Type: MSSQL related Operating System: Windows 2003 Server PHP Version: 5.2.3 New Comment: RTFM: http://php.net/mssql_connect "If a second call is made to mssql_connect() with the same arguments, no new link will be established, but instead, the link identifier of the already opened link will be returned. " To create separate link you need to use the 4th optional boolean parameter (set to true). Previous Comments: ------------------------------------------------------------------------ [2007-08-23 00:45:50] memso at memso dot net Description: ------------ After creating a MSSQL connection, any subsequent connections to MSSQL, whether persistant or otherwise, using the same server and login information, will override the original MSSQL connection. Using two different logins do not cause the problem. This has been tested and found to occur in PHP 5.2.0 and 5.2.3 for Windows (Windows 2003 Server) as well as PHP 5.2.3 for Linux (a heavily customized v2.2.24). This is very similar to Bug #17305. Reproduce code: --------------- $testquery = "SELECT EMAILADDRESS FROM adminmain WHERE ID = 1"; $conn1 = mssql_connect("localhost", "sa", "********"); mssql_select_db("generic", $conn1); // First Query! $result = mssql_query($testquery, $conn1); $qarray = mssql_fetch_array($result); echo("First Result: " . $qarray["EMAILADDRESS"] . "<br />"); $conn2 = mssql_connect("localhost", "sa", "********"); mssql_select_db("buymanitou", $conn2); // Second Query! // NOTE THAT THIS IS ON CONN1 AGAIN! $result = mssql_query($testquery, $conn1); $qarray = mssql_fetch_array($result); echo("Second Result: " . $qarray["EMAILADDRESS"] . "<br />"); mssql_close($conn1); mssql_close($conn2); Expected result: ---------------- In my test case, I am grabbing an email address from the first administrator in the system from the first database connection. Since in my case, the first DB connection returns fakeemailaddress@something.net , I expect the following output: First Result: fakeemailaddress@something.net Second Result: fakeemailaddress@something.net Actual result: -------------- Because of the bug, the email address from the SECOND database is returned for the second query: First Result: fakeemailaddress@something.net Second Result: anotheraddress@somethingelse.com ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42392&edit=1

« previous php.bugs (#116527) next »