无法通过PHP 5.3.0在SQlite3上写入chmod 777数据库文件 [英] Unable to write to a chmod 777 database file on SQlite3 via php 5.3.0

查看:66
本文介绍了无法通过PHP 5.3.0在SQlite3上写入chmod 777数据库文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将数据插入我的SQlite3数据库(通过命令行工作). 我给data1.db文件777授予了权限,但仍然说它无法打开文件.

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.

我收到此错误:

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

使用此代码:

$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));

我正在运行PHP 5.3.0

I'm running PHP 5.3.0

推荐答案

如果要更改包含SQLite文件的文件夹,则Web用户必须是可写的. .db文件可写还不够.

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.

请参见为什么不能通过我的Perl CGI脚本将DBD :: SQLite插入数据库吗?

这篇关于无法通过PHP 5.3.0在SQlite3上写入chmod 777数据库文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆