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