ID: 42392 Updated by: [EMAIL PROTECTED] 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 [EMAIL PROTECTED] , I expect the following output: First Result: [EMAIL PROTECTED] Second Result: [EMAIL PROTECTED] Actual result: -------------- Because of the bug, the email address from the SECOND database is returned for the second query: First Result: [EMAIL PROTECTED] Second Result: [EMAIL PROTECTED] ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42392&edit=1