title: Using PHP to connect to SQL Server 2005
body: <p>Hi I am using a PHP script to connect to SQL Server 2005. After much tinkering around I can finally establish a connection. However when I try and query the database I am getting no response. I have tested my SQL Query on the database and it runs fine. Any help greatly appreciated. Thanks</p>
  
  <pre><code>&lt;?php
  /
  
  $serverName = "*******";
  $usr="******";
  $pwd="****";
  $db="*****";
  
  
  
  //Connection to Database
  $connectionInfo = array("UID" =&gt; $usr, "PWD" =&gt; $pwd, "Database" =&gt; $db);
  
  $conn = sqlsrv_connect($serverName, $connectionInfo);
  if( $conn )
  {
       echo "Connection to database established.\n";
  
  }
  else
  {
       echo "Connection could not be established.\n";
       die( print_r( sqlsrv_errors(), true));
  }
  
  //-----------------------------------------------
  // Perform operations with connection.
  //-----------------------------------------------
  
  $sql = "SELECT ContactName FROM dbo.TBL_JOB WHERE EngineerID = 1 ";
  
  
  /* Close the connection. */
  sqlsrv_close( $conn);
  ?&gt;
  </code></pre>