# MS IIS PHP connection to MS SQL Server help

**URL:** <https://www.phphelp.com/t/ms-iis-php-connection-to-ms-sql-server-help/25874>\
**Category:** General Database (Oracle, SQL Server, etc)\
**Created:** [May 8, 2017, 3:55pm UTC](https://www.phphelp.com/t/ms-iis-php-connection-to-ms-sql-server-help/25874 "2017-05-08T15:55:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dstran](https://www.phphelp.com/letter_avatar_proxy/v4/letter/d/4491bb/32.png) [@dstran](https://www.phphelp.com/u/dstran)\
**Post date:** [May 8, 2017, 3:55pm UTC](https://www.phphelp.com/t/ms-iis-php-connection-to-ms-sql-server-help/25874/1 "2017-05-08T15:55:48Z")

</div>

Windows 2012 R2 64 bit  
MS IIS 8.5, PHP 7.1.1 on one server  
MS SQL 2012 on a different server  
Can’t connect to DB

1. downloaded SQLSRV4.0, extracted and placed in php/ext dir
2. added to php.ini  
[PHP\_SQLSRV\_71\_NTS]  
extension=php\_sqlsrv\_71\_nts.dll  
[PHP\_PDO\_SQLSRV\_7\_TS\_X64]  
extension=php\_pdo\_sqlsrv\_7\_ts\_x64.dll
3. I can see info in the phpinfo()
4. I can run php code
5. can NOT connect to MS SQL Server (no errors showing up, just blank page)

$serverName = “Servername”; //serverName\instanceName  
$connectionInfo = array( “Database”=\>“dbname”); //, “UID”=\>“userName”, “PWD”=\>“password” // I tried with user/pass also

$conn = sqlsrv\_connect( $serverName, $connectionInfo);

if( $conn ) {  
echo “Connection established.  
”;  
}else{  
echo “Connection could not be established.  
”;  
die( print\_r( sqlsrv\_errors(), true));  
}

Tried including username and password  
Please help me connect to DB,  
thank you.
