I used PHP to create a database with a table. I did it in the following way:
<?php
$db = new SQLiteDatabase("test.db");
unset($db);
$db = sqlite_open("test.db");
sqlite_query($db,"create table students (names char(255))");
sqlite_close($db);
?>
After I execute my PHP file from the command line: "php test.php" I get a new file in my directory which is called "test.db" (this is what I wanted). Than, in the command line, I type "sqlite3 test.db". In this way I enter in the sqlite command line session. Then, withing sqlite3, I type ".tables" (I wanted to check if a new database contains tables which it is supposed to contain). As the result I get:
Error: file is encrypted or is not a database
So, it does not work. Does anybody know something about this problem? Thank you in advance for any help.
This is a version mismatch issue.
To open a database using PHP5 and SQLite we need to use a PDO and not the
sqlite_open()
function. An example of how to open or create a database: