title: Why can't I connect to my mssql database using PHP?
body: <p>I've done so much research trying to get my PHP code hosted on IIS to connect to my MSSQL database. I just can't seem to figure out the issue. Has anyone come across this before? </p>
  
  <pre><code>&lt;?php
  
  $serverName = 'AEGIS-PC\SQLEXPRESS';
  $connectionInfo=array('Database'=&gt;'tttb_db');
  
  $con = sqlsrv_connect($serverName, $connectionInfo);
  if($con){
      echo 'Connection established&lt;br /&gt;';
  }
  else {
      echo 'Connection failed&lt;br /&gt;';
      die(print_r(sqlsrv_errors(), TRUE));
  }
  
  ?&gt;
  </code></pre>
  
  <p>Update, we have a new error:</p>
  
  <blockquote>
    <p>Connection failed
    Array ( [0] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [code] => 18456 [2] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Login failed for user 'NT AUTHORITY\IUSR'. [message] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Login failed for user 'NT AUTHORITY\IUSR'. ) [1] => Array ( [0] => 42000 [SQLSTATE] => 42000 [1] => 4060 [code] => 4060 [2] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Cannot open database "tttb_db" requested by the login. The login failed. [message] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Cannot open database "tttb_db" requested by the login. The login failed. ) [2] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [code] => 18456 [2] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Login failed for user 'NT AUTHORITY\IUSR'. [message] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Login failed for user 'NT AUTHORITY\IUSR'. ) [3] => Array ( [0] => 42000 [SQLSTATE] => 42000 [1] => 4060 [code] => 4060 [2] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Cannot open database "tttb_db" requested by the login. The login failed. [message] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Cannot open database "tttb_db" requested by the login. The login failed. ) )</p>
  </blockquote>
  
  <p>Our SQL server is using Windows Authentication and our server name is <code>AEGIS-PC\SQLEXPRESS</code> with the user name and password blocks are greyed out. I can not think of reason our login would be failing. What are we doing wrong?</p>