Error connecting to MSSQL with SQLSrv and PHP 5.4.7
php, sql-server
Solution
My install process actually worked, but the connection was indeed invalid. I should have been using the IP address as the host name, which I was not. I was also using a colon instead of a comma before the port number. Finally, no spaces can be allowed in the connection string, which I thought would be automatically stripped out. So, here's a valid connection string for those of you that may find yourself in a similar predicament:
$connectionString="sqlsrv:Server=123.123.12.1,9864;Database=mssqldatabaseWootWoot";
Also, in response to my earlier observation about that function sqlsrv_connect, I had not enabled the driver necessary for that function. It is located in php_sqlsrv_54_ts.dll, which after enabling, reported the function as existing.
Thanks to anyone who put any time into solving this.
Problem
I'm trying to connect to an MSSQL database with PHP and encounter a very frustrating error while trying to connect. It loads for a minute, before printing out the following message: ``` Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[08001]: [Microsoft][SQL Server Native Client 11.0]Named Pipes Provider: Could not open a connection to SQL Server [53]. ``` Here's my connection string: ``` DB::config("sqlsrv:Server={$dbHost} ; Database={$dbName}", $dbUser, $dbPass); ``` And in my DB class: ``` public static function config($dsn, $user, $pass) { self::$_pdo = @new PDO($dsn, $user, $pass); ...// intentionally left out ``` I'm very baffled. I have the following module configured in my php.ini file: extension=php_pdo_sqlsrv_54_ts.dll. Although I think I installed it right and I don't receive any error message about the driver not working, this bit of PHP prints nothing: ``` if (function_exists( 'sqlsrv_connect' )) echo "hey"; ``` and as you can see from my error message above SQL Server Native Client 11 appears to be working. I'm on a Windows platform. I tried disabling the firewall to no avail. I don't have much information about the SQL server or I would share it here. This is my first time posting on Stack, so I apologize if I'm leaving out a key piece of information or I'm not following proper etiquette in some way, but any help is definitely appreciated. Also, I should add that I've already done too much Googling, and haven't had any success.