title: PHP: How do I establish a connection to my SQL Server?
body: <p>I usually use my SQL Server with SQL Server Management Studio.  When logging in there I use Windows Authentication and do not specify a Username/Password. So the username/password I'm using at the moment is the same I use logging onto my computer. I'm attempting to establish a connection to the server through PHP; however, I get the an error. Anyone know what I am doing wrong?</p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>    $serverName = "MYPCNAME"; 
  
      $connectionInfo = array( "Database"=&gt;"College", "UID"=&gt;"MYUSERNAME", "PWD"=&gt;"MYPASSWORD");
  
      $conn = sqlsrv_connect( $serverName, $connectionInfo);
  
      if( $conn ) {
           echo "Connection established.&lt;br /&gt;";
      }else{
           echo "Connection could not be established.&lt;br /&gt;";
           die( print_r( sqlsrv_errors(), true));
      }
  </code></pre>
  
  <p><strong>Error</strong></p>
  
  <pre><code>Connection could not be established.
  Array ( [0] =&gt; Array ( [0] =&gt; 28000 [SQLSTATE] =&gt; 28000 [1] =&gt; 18456 [code] =&gt; 18456 [2] =&gt; [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'MYUSERNAME'. [message] =&gt; [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'MYUSERNAME'. ) [1] =&gt; Array ( [0] =&gt; 28000 [SQLSTATE] =&gt; 28000 [1] =&gt; 18456 [code] =&gt; 18456 [2] =&gt; [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'MYUSERNAME'. [message] =&gt; [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'MYUSERNAME'. ) )
  </code></pre>