I have computer, A, with a PHP program that connects and manipulates DB in computer B1. For the connection to the MS SQL server, I use the following script, which works well. There is only one account on this SQL server, and it is “sa”.
$server = 'WAREHOUSE1\MYDB';
$connectionInfo = array("UID" => "sa", "PWD" => "something", "Database"=>"MYDB");
$dbcMssql = sqlsrv_connect($server, $connectionInfo);
We got a new computer, B2, to replace this computer because it was old and slow. I set up the new DB and restored it from B1’s, set up firewall settings just like in B1, checked “allow remote connection” and selected “SQL Swrver and Windows Auth. mode” in MS SQL Server Management Studio, etc.. I am able to connect on the DB’s on computers B1 and B2 from computer A using MS SQL Server Management Studio. I’ve even linked the tables to MS Access (OBDC database) using the same user id (“sa”) and password.
The problem is that on the new computer, B2, my PHP script doesn’t work anymore, even though I can connect to it using the MS SQL program. I don’t recall setting up anything other than what I’ve already done when I was setting up B1. The error is as follow from sqlsrv_errors().
[SQLSTATE] => 28000
[code] => 18456
[message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'sa'.
The error is not logged for some reason in the errorlog file on the server folder for some reason, so I don’t know what the state of the error is.. What could be the problem? I have read several articles this entire afternoon, but I’m unable to make this work! Again, connection to B1 from A is fine, which leads me to believe that I didn’t set something on B2. B1 and B2 have same version SQL servers.
IRC the TCP/IP protocol is disabled by then default installation. You need to go to SQL Server Config and enable it from there.
Edit: Ok, just read it again, and if you are able to connect remotelly via TCP/IP then it should work from your PHP script aswell. Are you sure the connection string ends up pointing at the right (B2? )server ? Can it be a name resolution issue?