title: PHP Can't Connect to MS SQL Express 2008
body: <p>I'm struggling to connect to my MS SQL Express 2008 edition from my PHP files, but it seems virtually impossible.</p>
  
  <p>I've found several guides/notes on teh intarweb solving the issues, but none of these have helped me any further.</p>
  
  <p>I've taken a script from another site and entered my database information, but I still get errors:</p>
  
  <pre><code>&lt;?php
  $myServer = "localhost";
  $myUser = "demo_basic";
  $myPass = "1234";
  $myDB = "demo_basic"; 
  
  //connection to the database
  $dbhandle = mssql_connect($myServer, $myUser, $myPass)
    or die("Couldn't connect to SQL Server on $myServer"); 
  
  //select a database to work with
  $selected = mssql_select_db($myDB, $dbhandle)
    or die("Couldn't open database $myDB"); 
  
  //declare the SQL statement that will query the database
  $query = "SELECT nitid, nisname ";
  $query .= "FROM navitems";
  
  //execute the SQL query and return records
  $result = mssql_query($query);
  
  $numRows = mssql_num_rows($result); 
  echo "&lt;h1&gt;" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned &lt;/h1&gt;"; 
  
  //display the results 
  while($row = mssql_fetch_array($result))
  {
    echo "&lt;li&gt;" . $row["nitid"] . $row["nisname"] . "&lt;/li&gt;";
  }
  //close the connection
  mssql_close($dbhandle);
  ?&gt;
  </code></pre>
  
  <p>I get this error:</p>
  
  <blockquote>
    <p>Warning: mssql_connect()
    [function.mssql-connect]: Unable to
    connect to server: localhost in
    C:\inetpub\vhosts\dexterholding.dk\httpdocs_rip\sql.php
    on line 8 Couldn't connect to SQL
    Server on localhost</p>
  </blockquote>
  
  <p>You can see for yourself at: <a href="http://www.dehold.net/_rip/sql.php" rel="nofollow noreferrer">http://www.dehold.net/_rip/sql.php</a></p>
  
  <p>Any ideas? 
  I'm running Windows Server 2008 with PLESK and PHP5 as FastCGI.</p>