#42923 [NEW]: mssql_pconnect with the same login and new_link set to true causes problems

From: Date: Thu, 11 Oct 2007 02:41:02 +0000
Subject: #42923 [NEW]: mssql_pconnect with the same login and new_link set to true causes problems
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-118378@lists.php.net to get a copy of this message
From: memso at memso dot net Operating system: Windows 2003 Server PHP version: 5.2.4 PHP Bug Type: MSSQL related Bug description: mssql_pconnect with the same login and new_link set to true causes problems Description: ------------ After creating a persistent MSSQL connection, any subsequent persistent connections to MSSQL, using the same server and login information with the fourth parameter (new_link) set to TRUE, will cause problems when using the first link again. This has been tested and found to occur in PHP 5.2.3 and 5.2.4 for Windows (Windows 2003 Server) on three very different servers. A completely different problem occurs in PHP 5.2.3 for Linux. Since PHP 5.2.4 didn't fix the problem in Windows, I haven't tried it yet in Linux. **NOTE: Using mssql_connect does NOT cause this problem. Also, if the login information is different for the two connections, this test example works properly. It seems to only occur from using mssql_pconnect with the same login information and $new_link set to TRUE. Reproduce code: --------------- <?php $testquery = "SELECT EMAILADDRESS FROM adminmain WHERE ID = 1"; $conn1 = mssql_pconnect("localhost", "sa", "******", TRUE); 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_pconnect("localhost", "sa", "******", TRUE); 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 (note that changing the two mssql_pconnect to mssql_connect, it works as expected): First Result: fakeemailaddress@something.net Second Result: fakeemailaddress@something.net Actual result: -------------- On the Windows Server, this is the output: First Result: fakeemailaddress@something.net Warning: mssql_query() [function.mssql-query]: Unable to set query in C:\...\test-mssql_pconnect.php on line 17 Warning: mssql_fetch_array(): supplied argument is not a valid MS SQL-result resource in C:\...\test-mssql_pconnect.php on line 18 Second Result: On the Linux server, PHP seems to crash or puke out. I do not get a log entry in my phperrors.log nor in my apache2/logs/domainname-error_log. However, as long as I use exit; before the second mssql_query call, I get output. If I move it to just afterwards, nothing shows up, so I'm assuming it's using mssql_query after creating the second connection that is having issues. Since these both may be due to the same issue, I am tracking it under a single report. -- Edit bug report at http://bugs.php.net/?id=42923&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42923&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42923&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42923&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=42923&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=42923&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=42923&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=42923&r=needscript Try newer version: http://bugs.php.net/fix.php?id=42923&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=42923&r=support Expected behavior: http://bugs.php.net/fix.php?id=42923&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=42923&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=42923&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=42923&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42923&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=42923&r=dst IIS Stability: http://bugs.php.net/fix.php?id=42923&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=42923&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=42923&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=42923&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=42923&r=mysqlcfg

« previous php.bugs (#118378) next »