title: SQLite on localhost with php doesn't work (Linux)
body: <p>I am trying to get my fist sqlite programs with php working on localhost but I can't get it to work. On my machine I have installed Sqlite3 and all works fine with C/C++.</p>
  
  <p>If I move created database to localhost, give read/write permissions to db file and try to access them through php I get following error message:</p>
  
  <blockquote>
    <p>file is encrypted or is not a database  </p>
  </blockquote>
  
  <p>Here is example code I use:</p>
  
  <pre><code>&lt;?php
  $dbhandle = sqlite_open("m_test1.db", 0666, $error);
  if (!$dbhandle) die ($error);
  
  $stm = "CREATE TABLE Friends(Id integer PRIMARY KEY," . 
     "Name text UNIQUE NOT NULL, Sex text CHECK(Sex IN ('M', 'F')))";
  $ok = sqlite_exec($dbhandle, $stm, $error);
  
  if (!$ok)
     die("Cannot execute query. $error");
  
  echo "Database Friends created successfully";
  sqlite_close($dbhandle);
  ?&gt;
  </code></pre>
  
  <p>If I run this code through browser when database don't exists then I get:</p>
  
  <blockquote>
    <p>unable to open database: /var/www/m_test1.db</p>
  </blockquote>
  
  <p>Info:</p>
  
  <blockquote>
    <p>sqlite_libversion: 2.8.17<br>
      phpversion: 5.3.2-1ubuntu4.14<br>
      linux Ubuntu 10.04</p>
  </blockquote>
  
  <p>By looking to phpinfo it seems that SQLite, SQLite3 and PDO_Sqlite is enabled.</p>
  
  <p>Any help to get this working will be appreciated.</p>
  
  <p>EDIT:
  Solution is: 'chmod ugo+rwx /var/www' :)<br>
  After that sqlite_open and PDO both can create database.</p>