Be careful when utilizing mssql_pconnect to connect to multiple databases on the same server using different credentials. For example:
<?php
$conn1 = mssql_pconnect('production-server','sa','1234');
mssql_select_db($conn1,'invoicelistdb');
$row = mssql_query('select top 10 * from invoices', $conn1);
$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.