title: SQLite/PDO - How to use/connect to database file (.db) on localhost (XAMPP)?
body: <p>I use XAMPP with </p>
  
  <ul>
  <li>PHP Version 5.4.7 </li>
  <li>PDO drivers - mysql, sqlite - enabled</li>
  <li>SQLite Library - 3.7.7.1 - enabled</li>
  <li>sqlite3 - SQLite3 module version - 0.7 - enabled</li>
  <li>sqlite3.extension_dir - <em>no value</em> - <em>no value</em></li>
  <li>API Extensions - mysql,mysqli,pdo_mysql </li>
  </ul>
  
  <p>So, if I understood well some tutorials, that's all I need to be able to start working. </p>
  
  <p>So, in C:\xampp\htdocs\my_project I copied <strong>database.db</strong> file (sakila downloaded from here: <a href="https://github.com/joshuakleveter/sakila_db/tree/master/public_html" rel="nofollow">https://github.com/joshuakleveter/sakila_db/tree/master/public_html</a> )</p>
  
  <p>Then I created index.php that looks like this: </p>
  
  <pre><code>&lt;?php
  
  try {
      $db = new PDO('sqlite:./database.db');
      $db-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  } catch(Exception $e) {
      echo 'Error: ';
      echo $e-&gt;getMessage();
      die();
  }
  </code></pre>
  
  <p>and when I run this there are no errors. As you can see, my path is /database.db. If I change it to just </p>
  
  <pre><code>$db = new PDO('sqlite:.database.db');
  </code></pre>
  
  <p>no errors. Or without dot: </p>
  
  <pre><code>$db = new PDO('sqlite:database.db');
  </code></pre>
  
  <p>or <strong>absolute</strong> path - there are no errors. </p>
  
  <p>Even worse, if I put wrong not existing .db name:</p>
  
  <pre><code>$db = new PDO('sqlite:daaaaaaaaaaaatabase.db');
  </code></pre>
  
  <p>also - there are no errors.</p>
  
  <p><strong>Can you tell me what am I doing wrong?</strong></p>
  
  <p>With all of the above paths I've tried the following:</p>
  
  <pre><code>$results = $db-&gt;query('select * from film');
  var_dump($results);
  die();
  </code></pre>
  
  <p>and I get "General error: 1 no such table", but the database.db has that table (I installed sqlite, opened that database in command line and checked - the database.db is OK).</p>