|
Posted by The Natural Philosopher on July 11, 2008, 7:18 pm
Please log in for more thread options Tim Streater wrote:
>
>> Tim Streater wrote:
>>> I have this script of a few lines, which runs as expected when I do it
>>> from the command line. It does one select followed by one insert on an
>>> SQLite database. The db in question has permissions guo+rwx.
>>>
>>> If I run it as a web page (this is under OS X Leopard), the select works
>>> but the insert fails with this exception:
>>>
>>> SQLSTATE[HY000]: General error: 14 unable to open database file
>>>
>>> Any reason PHP cannot write to a file from apache?
>>>
>>> Here is the script:
>>>
>>>
>>> $dbh = new PDO ("sqlite:/opsdb");
>>>
>>> $dbh->setAttribute (PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
>>>
>>> $resq = $dbh->query ("select firstname from contact where absid=1");
>>> $resn = $resq->fetchAll ();
>>> echo "Name = '" . $resn[0]["firstname"] . "'<br>\n<br>\n";
>>>
>>> $res = $dbh->query ("insert into contact (absid) values (null)");
>>> $absid = $dbh->lastInsertId ();
>>>
>>> echo "absid='" . $absid . "'<br>\n";
>>>
>>> Thanks -- tim
>> Not sure its relevant, but apache runs as a different user than you
>> running code on the command line.
>
> Right. But as I mentioned, permissions are guo+rwx, so it should be
> read/write for anyone.
Try su-ing to the apache user and see if it still works, anyway.
|