title: Why can't I connect to mssql server? (PHP)
body: <p>I'm using the following code to try and connect using: </p>
  
  <pre><code>try {
     $hostname = "***********";
     $port = *****;
     $dbname = "******";
     $username = "******";
     $pw = "********";
     $dbh = new PDO ("sqlsrv:host=$hostname:$port;dbname=$dbname","$username","$pw");
   } catch (PDOException $e) {
     echo "Failed to get DB handle: " . $e-&gt;getMessage() . "\n";
     exit;
   }
  </code></pre>
  
  <p>but I'm getting the following error: </p>
  
  <pre><code>Failed to get DB handle: could not find driver
  </code></pre>
  
  <p>How do I fix this error?</p>
  
  <p>I've seen other answers say that I should have "SQL Server PDO Driver" installed. Is there a way to check this is installed?</p>