note 99723 added to pdo.exec

From: Date: Wed, 01 Sep 2010 15:37:41 +0000
Subject: note 99723 added to pdo.exec
Groups: php.notes 
Request: Send a blank email to php-notes+get-172240@lists.php.net to get a copy of this message
I spent half a day trying to work out why I could not update my sqlite3 database from apache using the PHP PDO driver. I was getting NO error messages at all. I could connect and select data, but not modify it. It wasn't until I added the following line: $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); after immediately opening the database, that I got a hint of what was happening. filename: File3 dl_count: 100 ( ! ) Warning: PDO::exec() [pdo.exec.html]: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /www/htdocs/test/dl-counter/sqlite-readwrite-test.php on line 76 Call Stack # Time Memory Function Location 1 0.0086 330120 {main}( ) ../sqlite-readwrite-test.php:0 2 0.0273 331240 PDO->exec( ) ../sqlite-readwrite-test.php:76 Affected Rows: '' filename: File3 dl_count: 100 The problem was with the file permissions. As root I could read and write the database from the sqlite3 command line monitor. But Apache was unable to write the database. Changed the permissions to 755 wwwrun:wwrun and it all works OK! Thanks again :) ---- Server IP: 69.147.83.197 Probable Submitter: 81.168.74.150 ---- Manual Page -- http://www.php.net/manual/en/pdo.exec.php Edit -- https://master.php.net/note/edit/99723 Del: integrated -- https://master.php.net/note/delete/99723/integrated Del: useless -- https://master.php.net/note/delete/99723/useless Del: bad code -- https://master.php.net/note/delete/99723/bad+code Del: spam -- https://master.php.net/note/delete/99723/spam Del: non-english -- https://master.php.net/note/delete/99723/non-english Del: in docs -- https://master.php.net/note/delete/99723/in+docs Del: other reasons-- https://master.php.net/note/delete/99723 Reject -- https://master.php.net/note/reject/99723 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#172240) next »