|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28235 SQLite returns null error message when database file isn't writable
Submitted: 2004-04-30 16:41 UTC Modified: 2004-07-18 01:00 UTC
Avg. Score:3.0 ± 2.0
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: simen at lunarlounge dot org Assigned:
Status: No Feedback Package: SQLite related
PHP Version: 5.0.0RC2 OS: Debian/GNU testing
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2004-04-30 16:41 UTC] simen at lunarlounge dot org
The SQLite extension fail to detect when a database file isn't writable:

Warning: sqlite_query() [function.sqlite-query]: (null) in test.php on line 12

Reproduce code:
# touch test.sqlite
# chmod 0600 sqlite
# sqlite test.sqlite

$db = sqlite_open('test.sqlite');

$sql = "INSERT INTO store (id, doc) VALUES (1, 'foo')";
$result = sqlite_query($db, $sql);

Expected result:
Warning: sqlite_query() [function.sqlite-query]: attempt to write a readonly database in test.php on line 12

Actual result:
Warning: sqlite_query() [function.sqlite-query]: (null) in test.php on line 12


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-05-13 12:43 UTC] nobody at example dot org
Never occured to me that this could be a bug, does the OO API handle this? 

  function connect(){
    try {
      if ( !$this->db_handle = @sqlite_open($this->db_name, 0666, $err) ){
        if ($this->db_handle===false){
          throw new DBEx('0: Could not open/create db or directory');
        } else {
          throw new DBEx(sqlite_last_error($this->db_handle).': '.
      } else { return true; }
    catch (DBEx $ex){ $ex->borkage(); return false; }
 [2004-07-10 14:48 UTC]
Please try using this CVS snapshot:
For Windows:

We upgraded the bundled sqlite library; please try the next snapshot (you might have to wait up to 3 hours) and see if this is fixed.
 [2004-07-18 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Sep 17 13:03:37 2021 UTC