1

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?

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.