Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
455 views
in Technique[技术] by (71.8m points)

sql - Unable to write to a chmod 777 database file on SQlite3 via php 5.3.0

I'm trying to insert data into my SQlite3 database (this works via the command line). I gave the data1.db file 777 permissions and still it says it's unable to open the file.

I get this error:

Warning: SQLite3::exec() [sqlite3.exec]: unable to open database file in /var/www/test.php on line 3

Using this code:

$db = new SQLite3('./data1.db');
$db->exec("INSERT INTO table1 (fileName) VALUES ('test.txt')");

But the strange thing is that I can read from the database: (this works)

print_r($db->querySingle('SELECT fileName FROM table1', true));

I'm running PHP 5.3.0

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The folder containing the SQLite file must be writeable by the web user, if you want to make changes to it. It's not enough that the .db file is writeable.

See Why can't DBD::SQLite insert into a database through my Perl CGI script?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...