title: Can't connect to SQL Server 2008 from PHP
body: <p>I have experience with mysql databases and have successfully connected to them with a couple dozen projects. </p>
  
  <p>Now, I’m having trouble connecting to a SQL Server 2008. This works: <code>&lt;?php phpinfo(); ?&gt;</code> and the sqlsrv and pdo_sqlsrv sections appear on this page. Here’s the code that I’m using to connect: </p>
  
  <pre><code>&lt;?php
  $serverName = "serverName\sqlexpress"; //serverName\instanceName
  $connectionInfo = array( "Database"=&gt;"dbName", "UID"=&gt;"userName", "PWD"=&gt;"password");
  $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));
  }
  ?&gt;
  </code></pre>
  
  <p>This code is straight from php.net here: <a href="http://www.php.net/manual/en/function.sqlsrv-connect.php" rel="nofollow noreferrer">http://www.php.net/manual/en/function.sqlsrv-connect.php</a>. The only changes I made were replacing serverName\sqlexpress with ##.#.#.##. And changing: dbName, username, password. </p>
  
  <p>Here is the results when I run the connection code above: </p>
  
  <blockquote>
    <p>Parse error: syntax error, unexpected '$serverName' (T_VARIABLE) in C:\inetpub\quote.myWebsite.com\index.php on line 23</p>
  </blockquote>
  
  <p>Even if I run something simple like this: </p>
  
  <pre><code>&lt;?php $myVariable = "someString"; ?&gt;
  </code></pre>
  
  <p>I get the same type of parse error: </p>
  
  <blockquote>
    <p>Parse error: syntax error, unexpected '$myVariable' (T_VARIABLE) in C:\inetpub\quote.myWebsite.com\index.php on line 23</p>
  </blockquote>
  
  <p>Why am I receiving the errors in my PHP code?</p>