How to configure SQLite3 for PHP 5.6.14 on Apache 2.4 (Windows 7)?

Cesare picture Cesare · Nov 26, 2015 · Viewed 23.1k times · Source

I'm on Windows 7, using PHP Version 5.6.14 on Apache 2.4 and I'm trying to access to a SQLite3 database.

I'm obtaining ....

Fatal error: Class 'SQLite3' not found

Here you're a simple php code ...

<?php
  $db = new SQLite3('phpdb');

  if ($db) {
    $db->query("CREATE TABLE dogbreeds (Name VARCHAR(255), MaxAge INT);");
    $db->query("INSERT INTO dogbreeds VALUES ('Doberman', 15)");
    $result = $db->query("SELECT Name FROM dogbreeds");
    var_dump($result->fetchArray(SQLITE3_ASSOC));
  } else {
    print "Connection to database failed!\n";
  }
?>

I've just looking for information about and based on this at the moment I've this configuration in my php.ini file ...

extension=php_pdo_sqlite.dll
extension=php_sqlite3.dll
sqlite3.extension_dir = "D:\Cesare\Lavoro\Utili\Php\5-6-14\ext"

Any suggestions? Thank you very much in advance ....

Cesare

Answer

Gary picture Gary · Nov 26, 2015

Enable extension php by removing the ";" in front of ";extension=php_sqlite3.dll" in php.ini. Can you also manually check if the extensions are there in the path?

`extension=php_pdo_sqlite.dll` AND `extension=php_sqlite3.dll`. 

Try this

$db = sqlite_open("/absolute/path/my_sqlite.db");

or

 $db = new SQLiteDatabase('filename')) 

http://php.net/manual/en/book.sqlite.php