note 108508 added to function.mssql-pconnect
| From: | kagaku at gmail dot com | Date: | Wed, 02 May 2012 18:47:48 +0000 |
| Subject: | note 108508 added to function.mssql-pconnect | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-187444@lists.php.net to get a copy of this message | ||
Be careful when utilizing mssql_pconnect to connect to multiple databases on the same server using
different credentials. For example:
<?php
/* first connection */
$conn1 = mssql_pconnect('production-server','sa','1234');
mssql_select_db($conn1,'invoicelistdb');
$row = mssql_query('select top 10 * from invoices', $conn1);
/* open another connection, same server different */
$conn2 = mssql_pconnect('production-server','loweruser','6789');
mssql_select_db($conn2,'someotherdb');
?>
Results in the error:
PHP Warning: mssql_select_db(): Unable to select database: someotherdb
I suspect mssql_pconnect detects a connect opened to "production-server" and just re-uses
it, regardless of whether or not the credentials are the same. We did not notice this until
consolidating two different MSSQL servers onto one server with two databases with different
users/permissions. Reverting back to mssql_connect() solves the problem.
----
Server IP: 192.41.42.26
Probable Submitter: 159.53.110.141
----
Manual Page -- http://www.php.net/manual/en/function.mssql-pconnect.php
Edit -- https://master.php.net/note/edit/108508
Del: integrated -- https://master.php.net/note/delete/108508/integrated
Del: useless -- https://master.php.net/note/delete/108508/useless
Del: bad code -- https://master.php.net/note/delete/108508/bad+code
Del: spam -- https://master.php.net/note/delete/108508/spam
Del: non-english -- https://master.php.net/note/delete/108508/non-english
Del: in docs -- https://master.php.net/note/delete/108508/in+docs
Del: other reasons-- https://master.php.net/note/delete/108508
Reject -- https://master.php.net/note/reject/108508
Search -- https://master.php.net/manage/user-notes.php