开发者

using sqlite with php and sqlite-programs

I'm trying to use sqlite with php.

I used some tutorial:

$db = sqlite_open("db.sqlite");

sqlite_query($db , "CREATE TABLE foo (id INTEGER PRIMARY KEY, name CHAR(255))");

sqlite_query($db, "INSERT INTO foo (name) VALUES ('Ilia')");
sqlite_query($db, "INSERT INTO foo (name) VALUES ('Ilia2')");
sqlite_query($db, "INSERT INTO foo (name) VALUES ('Ilia3')");

$result = sqlite_query($db, "SELECT * FROM foo");

while ($row = sqlite_fetch_array($result)) print_r($row);

It works, but file db.sqlite can't be opened by any sqlite program. And vice-versa, files that were created by sqlite programs can't be opened with php sqlite_open:

W开发者_StackOverflow中文版arning: sqlite_open() [function.sqlite-open]: file is encrypted or is not a database in ...\public_html\test\test.php on line 2

What can be the problem here?


Maybe it's the SQLite version?

sqlite_open() only creates / reads SQLite 2 databases.

I suggest you move to the far better sqlite: (version 3) and sqlite2: (version 2) PDO drivers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜