tags:

views:

110

answers:

1

Hi, 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:

Warning: 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?

+3  A: 

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.

Alix Axel