title: PHP / Xampp / PDO - Connect locally with xampp to a online database with the PDO library in PHP
body: <p>Basically the title,</p>
  
  <p>When I attempt to connect to a database I get the error: <code>could not find driver</code>.</p>
  
  <p>I've searched online and it was said I had to uncomment several extensions.
  I uncommented <code>extension=php_pgsql.dll</code> and <code>extension=php_pdo_pgsql.dll</code> in the <code>php.ini</code> in <code>C:\xampp\php</code>, but that didnt solve it.</p>
  
  <p>When I run my code on the online server the database connection works.
  I'm using PDO for the database to a MSSQL server.</p>
  
  <p>Basic information:</p>
  
  <ul>
  <li>I'm using XAMPP Control Panel V3.2.2 on Windows</li>
  <li><p>I connect like so: </p>
  
  <pre><code>define("USER_NAME", "myusername");
  define("DATABASE", "mydatabase");
  define("PASSWORD", "mypassword");
  define("HOST", "myhost");
  
  try{
      $db = new PDO("dblib:host=".HOST.";dbname=".DATABASE, USER_NAME, PASSWORD);
      $db-&gt;setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
  }catch(PDOException $exception){
      echo $exception-&gt;getMessage();
      exit;
  }
  </code></pre></li>
  </ul>
  
  <p><strong>EDIT</strong></p>
  
  <p>I downloaded MSSQL driver for PDO.
  I added these two extensions: </p>
  
  <pre><code>extension=php_sqlsrv_54_ts.dll
  extension=php_pdo_sqlsrv_54_ts.dll
  </code></pre>
  
  <p>Without success.</p>