I have found the problem. PHP was happily reporting that the frontend.db
file itself is writeable (which was true all the time), but the
directory containing the database was not writeable by the webserver.

I find this to be a bit irritating - shouldn't it be enough that the
server can dive into that subdir and find a file it can actually write
to within the dir? How does it make sense that the entire directory
containing the directory must be writeable? Is this an SQLite
requirement or a PHP quirk?

This way I will have to make a new directory exclusively for the
database, because I do not want all scripts to have write access to the
whole main dir...

CU
 Markus

Am Donnerstag, den 04.10.2007, 23:37 +0200 schrieb Markus Wolff:
> Hello everone,
> 
> I'm having a really weird problem with SQLite when used with PHP - I'm 
> pretty sure it's not SQLite that's at fault here, but since in the 
> PHP-DB mailingliste nobody seemed to be able to help me, I'm hoping to 
> get some insights here :-)
> 
> I'm trying to open an SQLite3 database from a PHP very simple PHP
> script:
> 
> $db = dirname(__FILE__).'/frontend.db';
> $pdo = new PDO('sqlite:'.$db);
> $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
> $pdo->query("SELECT * FROM page LIMIT 1");
> echo "Deleting pages\n";
> $pdo->query("DELETE FROM page");
> echo "Deleting websites\n";
> $pdo->query("DELETE FROM website");
> 
> The database file contains no data whatsoever, just the table
> definitions (in case you were wondering, this is a stripped-down version
> of a larger script for debugging purposes, hence the seemingly idiotic
> DELETE statements that won't do any good in an empty database anyway,
> but I digress...).
> 
> When executed on the command line, this works perfectly. When I execute
> the same script via Apache and mod_php, I'm getting this exception:
> 
> PDOException: SQLSTATE[HY000]: General error: 1 SQL logic error or
> missing database in /home/mwolff/webs/markus/cms/test.php on line 8
> 
> Getting experimental, I've tried to change the calls for the DELETE
> statements from $pdo->query() to $pdo->exec(), just to see what happens.
> Well, what happens is that I'm getting a different error:
> 
> PDOException: SQLSTATE[HY000]: General error: 14 unable to open database
> file in /home/mwolff/webs/markus/cms/test.php on line 6
> 
> Argh... what can possibly be wrong here? The script works from the
> commandline, with the exact same PHP version (Debian package, PHP
> 5.2.0-8+etch7, and we also tried upgrading to the latest Debian package
> of 5.2.4, to no avail).
> 
> It can't be file permissions, I've even tried to set the database file
> to 777... no change at all.
> 
> 
> For the previous discussion in the PHP-DB mailinglist, see here 
> (starting point, same content as above):
> http://marc.info/?l=php-db&m=119134768316086&w=2
> 
> A detailed step-by-step list for reproducing the problem, including the 
> used SQL schema, can be found here:
> http://marc.info/?l=php-db&m=119143000125909&w=2
> 
> I hope someone here can point me in the right direction, I'm getting 
> somewhat desperate :-)
> 
> Thanks,
> Markus
> 
> 
-- 
Mit freundlichen Grüßen
Markus Wolff
Development

NorthClick GmbH

Gasstr. 10 - 22761 Hamburg
Tel.: 040 8 22 44 999 - Fax: 040 8 22 44 998
Internet: http://www.northclick.de/

Geschäftsführer: F. Detzner | M. Henze | C. Springub
Amtsgericht Hamburg, HRB 94459


-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to