title: Connecting PHP to MS SQL Server
body: <pre><code>&lt;?php
  $serverName = "(local)"; //serverName
  $connectionInfo = array( "Database"=&gt;"DabaseNew", "UID"=&gt;"sa", "PWD"=&gt;"*****");
  $conn = sqlsrv_connect( $serverName, $connectionInfo);
  if( $conn==true ) {
      echo "Connection established.&lt;br /&gt;";
  }else{
      echo "Connection could not be established.&lt;br /&gt;";
      die( print_r( sqlsrv_errors(), true));
  }
  $sql = "SELECT * FROM Dbo.DATABASE COMPANY SERVICES$Employee";
  $stmt = sqlsrv_query( $conn, $sql);
  if(!$stmt){
      die( print_r( sqlsrv_errors(), true));
  }
  $rows = sqlsrv_has_rows($stmt);
  while($obj = sqlsrv_fetch_object( $stmt)){
      echo $obj-&gt;Description.", ".$obj-&gt;lName."&lt;br /&gt;";
  }
  ?&gt;
  </code></pre>
  
  <p>I am trying to connect to php to my sql server using sqlsrv_connect. The above code gives me an error below;</p>
  
  <p>Output:
  Connection established.
  Array ( [0] => Array ( [0] => 42000 [SQLSTATE] => 42000 [1] => 102 [code] => 102 [2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Incorrect syntax near 'SERVICES'. [message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Incorrect syntax near 'SERVICES'. ) ) </p>