<?php
$sqlite = new SQLiteDatabase('music.db') or die ("Could not open database");
$sql = "SELECT artist_id, artist_name FROM artists";
if ($result = $sqlite->query($sql)) {
if ($result->numRows() > 0) {
while($row = $result->fetch()) {
echo $row[0] . ":" . $row[1] . "\n";
}
} else {
echo "No records matching your query were found.";
}
} else {
echo "ERROR: Could not execute $sql. " . sqlite_error_string($sqlite->lastError());
}
unset($sqlite);
?>
Then I get this errormessage:
Quote
Fatal error: Uncaught exception 'SQLiteException' with message 'SQLiteDatabase::__construct() [<a href='sqlitedatabase.--construct'>sqlitedatabase.--construct</a>]: file is encrypted or is not a database' in D:\xampp\htdocs\sqlite\music.php:3 Stack trace: #0 D:\xampp\htdocs\sqlite\music.php(3): SQLiteDatabase->__construct('music.db') #1 {main} thrown in D:\xampp\htdocs\sqlite\music.php on line 3
I've checked the php.ini if the sqlite extension is "switched on", which it is. A few pages later in the book this same db-file is used with pdo, and then the querying works fine.
What could be going wrong?
Thank,
Bart

New Topic/Question
Reply




MultiQuote






|