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.
Inspect the first 16 bytes of the database file directly, if they are equal to the string "SQLite format 3\000" then the file is not encrypted, and is a standard SQLite database. If something happens and a crash occurs during sqlcipher_export, the original database will be left untouched.
To encrypt a file: Close all the database files that you are going to encrypt. Choose Tools menu > Developer Utilities. If you have used Developer Utilities on the same custom app before and saved your settings, click Load Settings, locate and select the appropriate .
SQLite is often used as the on-disk file format for desktop applications such as version control systems, financial analysis tools, media cataloging and editing suites, CAD packages, record keeping programs, and so forth.
Make sure that the /tmp directory is globally writable. Make sure that the path to the database specified in settings.py is a complete path. Make sure there are no special characters in the path. On Windows, make sure the db directory path is written with double backslash.
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:
try { /*** connect to SQLite database ***/ $dbh = new PDO("sqlite:VPN0.sqlite"); echo "Handle has been created ...... <br><br>"; } catch(PDOException $e) { echo $e->getMessage(); echo "<br><br>Database -- NOT -- loaded successfully .. "; die( "<br><br>Query Closed !!! $error"); } echo "Database loaded successfully ....";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With