Does it appear in phpinfo() as one of the extensions?
(and why not just use the PDO_sqlite driver in any case)
I am still smarting over lost hours on this today, but if you were to make your database with some GUI tool, make sure it doesn’t make an sqlite2 database for you, or you will end up with less hair than me.
If it tells you it can convert it to sqlite3 then do not believe it.
PHP is telling you the function does not exist. Are you forgetting to include something in your index.php file? Does SQLite have some .php files you need to include in the php you want to use its functions in?
sqlite3
SQLite3 support enabled
SQLite3 module version 0.7-dev
SQLite Library 3.6.15
Directive Local Value Master Value
sqlite3.extension_dir no value no value
And here is my code:
<?php
/*
* create a SQLite3 handle.
*
* Note: in-memory database are created by the magic keyword ":memory:"
*
*/
$db = sqlite3_open(":memory:");
if (!$db) die ("Could not create in-memory database..");
/*
* create a simple test and insert some values..
*/
$ret = sqlite3_exec ($db, "CREATE TABLE test (id INTEGER, name TEXT, age INTEGER);");
if (!$ret) die (sqlite3_error($db));
sqlite3_exec($db, "INSERT INTO test (id,name,age) VALUES (1,'michael',32)");
sqlite3_exec($db, "INSERT INTO test (id,name,age) VALUES (2,'bob',27)");
sqlite3_exec($db, "INSERT INTO test (id,name,age) VALUES (3,'martin',12)");
/*
* Create a query
*/
$query = sqlite3_query($db, "SELECT * FROM test ORDER BY age DESC");
if (!$query) die (sqlite3_error($db));
/*
* sqlite3_fetch_array() returns an associative array
* for each row in the result set. Key indexes are
* the columns names.
*/
while ( ($row = sqlite3_fetch_array($query)))
{
printf("%-20s %u\
", $row['name'], $row['age']);
}
/*
* do not forget to release all handles !
*/
sqlite3_query_close($query);
sqlite3_close ($db);
?>