title: PDO SQLite cannot update record: "database is locked"
body: <p>I'm struggling with this all day. I've read numerous posts, tried all suggestions but nothing works.</p>
  
  <p>This is my PHP code:</p>
  
  <pre><code>try {
  $db = new PDO('sqlite:test.db');
  $db-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  
  $result = $db-&gt;query('SELECT * FROM v_test');
  
  foreach ($result as $row) {
    echo $row['column1'] . " | " . $row['column2'] . "&lt;br&gt;";
  
    /**************************************
    * Update table                        *
    **************************************/
    if (!$db-&gt;exec("update test set column2 = date('now') where column1 ='" . $row['column1'] . "';") === TRUE) {
      echo "Cannot update date:" . $db-&gt;lastErrorMsg();
      $db = null;
      exit;
    } 
  }
  
  /**************************************
  * Close db connections                *
  **************************************/
  $db = null;
  }
  catch(PDOException $e) {
    echo "PDOException: " . $e-&gt;getMessage() . "&lt;br&gt;";
  
    /*** show the error info ***/
    foreach($db-&gt;errorInfo() as $error)
    {
      echo $error.'&lt;br /&gt;';
    }
  
    $db = null;  
  }
  </code></pre>
  
  <p>I run PHP v5.3.3.
  With just the loop after the select I get the correct values from the table, so I can access the database, which is in the same folder as my script. The folder has 0777 rights, the database and the script both have 0660, but I've also tried with 0777. But when I try to update a record I get the 'database is locked' error.</p>
  
  <p>I've used the same database before on a different server, but not with PDO but with <code>$db = new SQLite3('mailing.db', SQLITE3_OPEN_READWRITE);</code> 
  I couldn't use the same script because SQLITE isn't enabled on the new server, but PDO_SQLITE is.</p>
  
  <p>My phpinfo() says: </p>
  
  <ul>
  <li>PDO drivers  mysql, odbc, pgsql, sqlite</li>
  <li>pdo_sqlite. PDO Driver for SQLite 3.x    enabled SQLite Library  3.3.6</li>
  <li>'--without-sqlite' </li>
  <li>'--without-sqlite3'</li>
  </ul>
  
  <p>Of course I tried to enable SQLite on the new server first so I could use the original script. But because I'm not a system engineer (just a developer ;)) I had hoped I could use the PDO option.</p>
  
  <p>Is my problem related to my PHP configuration or is my script wrong?</p>