Reputation: 1749
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
Upvotes: 8
Views: 28841
Reputation: 1
System xuname: Void 4.19.118_1 armv7l Unknown uptodate rF package: php-7.4.5_1, php-sqlite-7.4.5_1 Actual behavior I'm trying to get the PHP SQLite3 extension to work on my Raspberry PI. I installed the above packages and enabled the extension in /etc/php/php.ini by uncommenting ;extension=sqlite3.
Executing php -m does not list sqlite as a PHP module. Executing php -i does not mention any SQLite3 support.
Expected behavior SQLite3 should work after installing php-sqlite-7.4.5_1 and enabling the extension in /etc/php/php.ini.
Steps to reproduce the behavior Install the above packages, enable SQLite3 extension and run php -r 'new SQLite3("db");':
Upvotes: -1
Reputation: 1
If you are using XAMPP click on "config" button select PHP(php.ini) then search "sqlite3" uncomment the ;extension=sqlite3 like this, extension=sqlite3 then find [sqlite3] and write the path where your php file and sqlite database reside like, [sqlite3] sqlite3.extension_dir ="D:\xampp\htdocs" then type localhost/yourphpfile.php in your browser you'll see the results of query.
Upvotes: 0
Reputation: 59
I ran into the same problem: -I am doing the LinkedIn Learning for SQL Essentials.
-My OS is windows server 2012 r2
-I downloaded xampp from this website https://bw.org/ldcsql/, given by the instructor. I specifically downloaded the xampp version on this website even though there is a newer one(I uninstalled the newer one and installed the one from the website).
-Installed sqlite from https://www.sqlite.org/download.html (downloaded sqlite-dll-win64-x64-3240000.zip for my computer and the "sqlite-tools-win32-86-3240000.zip"). I unzipped them and copied the DLL and the def(from dll 64) to system32 folder and the "sqlite3" Application (from sqlite-tools) to system32 as well. A reference website just in case https://mislav.net/rails/install-sqlite3/
Note: when I say "install" it means that I pasted the files to the system32, there is no wizard installation or anything else.
-In C:\xampp\php I looked for the php.ini which is of type "Configuration Settings", is NOT the php.ini-production NOR the php.ini-development. Inside there these should be uncommented: extension=pdo_mysql, extension=pdo_sqlite and extension=sqlite3.
-Also in C:\xampp\php\ext check that you have php_pdo_mysql.dll, php_pdo_sqlite.dll and php_pdo_sqlite3.dll
And after all that it worked
Upvotes: 0
Reputation: 113
I met the same problem, I solved it by changing the "extension_dir" using the absolute path
extension_dir = "C:/php/php7.0/ext"
the others setting
extension=php_pdo_sqlite.dll
extension=php_sqlite3.dll
sqlite3.extension_dir = "C:/php/php7.0/ext"
Upvotes: 2
Reputation: 2339
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
Upvotes: 6