简体   繁体   中英

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

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

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

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"

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

如果您使用 XAMPP,请单击“配置”按钮选择 PHP(php.ini) 然后搜索“sqlite3”取消注释 ;extension=sqlite3 像这样,extension=sqlite3 然后找到 [sqlite3] 并写下您的 php 文件和 sqlite 的路径数据库位于 [sqlite3] sqlite3.extension_dir ="D:\\xampp\\htdocs" 然后在浏览器中输入 localhost/yourphpfile.php 你会看到查询的结果。

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");':

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM