Class sqlite3 not found php windows

Im using ubuntu 12.04, and php 5.x I need to use sqlite3 in it but Im getting an error of php fatal error: class sqlite3 not found I done all the installation processes, like $ sudo apt-get i...

Im using ubuntu 12.04, and php 5.x I need to use sqlite3 in it but Im getting an error of

php fatal error: class sqlite3 not found

I done all the installation processes,

like

$ sudo apt-get install php5-cli php5-dev make
$ sudo apt-get install libsqlite3-0 libsqlite3-dev
$ sudo apt-get install php5-sqlite3
$ sudo apt-get remove php5-sqlite3
$ cd ~
$ wget http://pecl.php.net/get/sqlite3-0.6.tgz
$ tar -zxf sqlite3-0.6.tgz
$ cd sqlite3-0.6/
$ sudo phpize
$ sudo ./configure
$ sudo make
$ sudo make install
$ sudo apache2ctl restart

and

cd /etc/php5/conf.d

cat > sqlite3.ini
# configuration for php SQLite3 module
extension=sqlite3.so
^D

sudo /etc/init.d/apache2 restart

now what else I want to do???

Can anyone please help me to fix this…

Thankyou In advance.

asked Oct 24, 2013 at 11:55

harishkumar329's user avatar

harishkumar329harishkumar329

1,2003 gold badges15 silver badges33 bronze badges

Found a solution my self,

I installed

 $ sudo apt-get install php5-sqlite

not

 $ sudo apt-get install php5-sqlite3

and using sqlite3 class only.. no issue now.

answered Oct 25, 2013 at 10:42

harishkumar329's user avatar

harishkumar329harishkumar329

1,2003 gold badges15 silver badges33 bronze badges

4

  • Step 1 :

    • For PHP5, use

      sudo apt-get install php5-sqlite
      
    • For PHP7.0, use

      sudo apt-get install php7.0-sqlite
      
    • For PHP7.1, use

      sudo apt-get install php7.1-sqlite
      
    • For PHP7.2, use

      sudo apt-get install php7.2-sqlite
      
    • For PHP7.3, use

      sudo apt-get install php7.3-sqlite
      
  • Step 2 :

    • Restart Apache

      sudo service apache2 restart
      

Hasta Dhana's user avatar

Hasta Dhana

4,6997 gold badges20 silver badges26 bronze badges

answered Aug 4, 2019 at 1:40

Bessem Bousselmi's user avatar

0

For the error PHP Fatal error: Uncaught Error: Class 'SQLite3' not found in /path/file.php:1 on ArchLinux:

Install the sqlite extension for PHP:

$ sudo pacman -S php-sqlite

Then edit /etc/php/php.ini and add:

extension=pdo_sqlite
extension=sqlite3

Source: 1

answered May 18, 2019 at 18:34

noraj's user avatar

norajnoraj

3,3141 gold badge27 silver badges37 bronze badges

I had the same problem even I have installed all libraries.
If you run php-fcgi, you should restart it:

sudo service php-fcgi restart

Try also restart apache:

sudo service apache restart 

answered Oct 6, 2015 at 15:07

Vasili Pascal's user avatar

Vasili PascalVasili Pascal

2,9241 gold badge27 silver badges20 bronze badges

My PHP is 7.3 so I used the following

For PHP7.3, use

sudo apt install php7.3-sqlite3

And don’t forget to restart your Apache2

sudo service apache2 restart

answered Jun 21, 2020 at 11:28

Mohamad Osama's user avatar

In order to install the missing class sqlite3, please run:

apt-get install php7.4-sqlite3

gpo's user avatar

gpo

3,2483 gold badges30 silver badges50 bronze badges

answered Nov 17, 2020 at 3:57

z3d's user avatar

0

I had the same error. If you are on Windows, don’t forget to uncomment php_sqlite3.dll (and optionally php_pdo_sqlite.dll) extension in php.ini. Save php.ini and start the script again.

(I added this answer to the question with the ubuntu tag because this question is on the first place in google for the request php sqlite3 not found).

answered Jan 7, 2019 at 6:45

AVKurov's user avatar

AVKurovAVKurov

1561 gold badge2 silver badges6 bronze badges

If you use XAMPP or anything else first close it.

  1. Go to this directory: xampp > php > php.ini (find this file php.ini on PHP folder)
  2. Open php.ini file with notepad
  3. Search «SQLite3»
  4. Remove «;» this line ;extension=sqlite3
  5. Finally be extension=sqlite3
  6. Save file
  7. Open XAMPP

gre_gor's user avatar

gre_gor

6,4069 gold badges45 silver badges52 bronze badges

answered Jul 11, 2022 at 21:39

mamadprog's user avatar

For php5.6 use:

sudo apt-get install php5.6-sqlite3

answered May 27, 2019 at 11:38

Pavel Alazankin's user avatar

Pavel AlazankinPavel Alazankin

1,2651 gold badge10 silver badges21 bronze badges

run this command in linux system or (based on your operating system and php versoin )

system info — ubuntu 20
php 7.4
server — php local

sudo apt-get install php7.4-sqlite3


then you need to restart the your web server app like apache, nginx, or local php server then try to run
you can run the code test sqlite working

<?php
   class MyDB extends SQLite3 {
      function __construct() {
         $this->open('sqlitedb.db');
      }
   }
   $db = new MyDB();
   if(!$db) {
      echo $db->lastErrorMsg();
   } else {
      echo "Opened database successfullyn";
   }
?>

create php file index.php

i am using php local server
enter image description here

 php -S localhost:8000

(http://localhost:8000) open that url
enter image description here

answered Apr 18, 2021 at 4:55

Mr Coder's user avatar

Mr CoderMr Coder

4913 silver badges13 bronze badges

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:xamppphp 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:xamppphpext check that you have php_pdo_mysql.dll, php_pdo_sqlite.dll and php_pdo_sqlite3.dll

And after all that it worked

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.

Already on GitHub?
Sign in
to your account


Closed

ILadis opened this issue

May 11, 2020

· 5 comments


· Fixed by #22019

Labels

bug

Something isn’t working

Comments

@ILadis

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

PHP Fatal error:  Uncaught Error: Class 'SQLite3' not found in Command line code:1
Stack trace:
#0 {main}
  thrown in Command line code on line 1

@jnbr
jnbr

added
the

bug

Something isn’t working

label

May 15, 2020

@jnbr
jnbr

mentioned this issue

May 15, 2020

@newbluemoon

Just did an install on my up-to-date RPi armv7l-musl and aarch64-musl. Running the command above succeeded. No error reported, an empty ‘db’ was created and php -m does report sqlite support.

On armv7l, however, it failed as above. I don’t have other systems to test handy right now.

It seems the cross built php does work, at least for musl systems. So what’s different on glibc systems?

@ILadis

I tried some other extensions and these did not work as well. So it does not seem to be a SQLite exclusive issue.

I also tried compiling php myself on the RPi by cloning this repository and running ./xbps-src pkg php. The package build without any errors and after installing it, everything worked as expected.

@newbluemoon

I think I found the solution, please test #22019 if it works for you.

@ILadis

I installed the updated version php-7.4.6_2 on my RPi and can confirm it’s working now. Thanks for fixing!

@prog98

if you use xampp or … first close xampp or …
go to this directori : xampp > php > php.ini ( find this file php.ini on php folder)
and open php.ini file with notepad
and search SQLite3
and remove ; this line ;extension=sqlite3
so finaly be extension=sqlite3
and save file
end open xampp

sorry my cant good speak english i hope i can help you.

Labels

bug

Something isn’t working

Имеется следующий код

class NewsDB implements INewsDB{
    const DB_NAME = __DIR__.'/news.db';
    private $_db;

    function __get($name) {
      // TODO: Implement __get() method.
      if($name == 'db'){
        return $this->_db;
      }
      throw new Exception('Unknown property!!!');
    }

    function __construct() {
      $this->_db = new SQLite3(self::DB_NAME);
    }

    function __destruct() {
      // TODO: Implement __destruct() method.
      unset($this->_db);
    }

    function saveNews($title, $category, $description, $source) {
      // TODO: Implement saveNews() method.
    }

    function getNews() {
      // TODO: Implement getNews() method.
    }

    function deleteNews($id) {
      // TODO: Implement deleteNews() method.
    }
  }

Создаю новый объект
$news = new NewsDB();

и получаю ошибку

Fatal error: Uncaught Error: Class 'SQLite3' not found in /var/www/test.site/public_html/news/NewsDB.class.php on line 17

Установил sqlite3, но это не помогло решить проблему.
Может есть какие-нибудь мысли куда двигаться дальше?
Заранее благодарен.

Рекурсивный акроним словосочетания «PHP: Hypertext Preprocessor»
Добро пожаловать на форум PHP программистов!

Главная
Документация
Новости
Форум

За последние 24 часа нас посетил 10461 программист и 1251 робот. Сейчас ищут 450 программистов …

Не получается настроить SQLite3 в PHP 5.4. Помогите настроить.

Тема в разделе «PHP для новичков», создана пользователем anbabai84, 12 авг 2016.


  1. anbabai84

    anbabai84
    Новичок

    С нами с:
    12 авг 2016
    Сообщения:
    3
    Симпатии:
    0

    Добрый день.

    Я только начинаю изучение PHP. Помогите настроить SQLite3. Что и как нужно прописать в php.ini, чтоб все работало. На данный момент при попытки открыть БД $db = new SQLite3(‘Term.db’);, вылезает ошибка Fatal error: Class ‘SQLite3’ not found in C:Apache24htdocstest3.php on line 3.

    #1


    anbabai84,

    12 авг 2016


  2. bikerlex

    bikerlex
    Активный пользователь

    С нами с:
    2 дек 2014
    Сообщения:
    341
    Симпатии:
    40

    Ставь уж тогда сразу PHP 7 или хотя бы 5.6

    В php.ini включено php_sqlite.dll ?
    https://php.ru/manual/sqlite.installation.html

    #2


    bikerlex,

    12 авг 2016

    Последнее редактирование: 12 авг 2016


  3. anbabai84

    anbabai84
    Новичок

    С нами с:
    12 авг 2016
    Сообщения:
    3
    Симпатии:
    0

    Да у меня на Win XP все настроено) Поставил последнюю версию поддерживающую XP.
    В php.ini не было такой строки, а была только extension=php_pdo_sqlite.dll. Хотя в папке ext есть php_sqlite3.dll.

    #3


    anbabai84,

    12 авг 2016


  4. denis01

    denis01
    Суперстар

    Команда форума
    Модератор

    С нами с:
    9 дек 2014
    Сообщения:
    12.236
    Симпатии:
    1.716
    Адрес:
    Молдова, г.Кишинёв

    Тогда в php.ini там где другие extension подключаются, добавь

    PHP:
    1. extension=php_sqlite3.dll

    ты искал через Ctrl+F точно не было php_sqlite3.dll в php.ini?

    #4


    denis01,

    12 авг 2016


  5. anbabai84

    anbabai84
    Новичок

    С нами с:
    12 авг 2016
    Сообщения:
    3
    Симпатии:
    0

    Нашел ) Комментарий снял, но ошибка осталась. Есть еще такая строка:
    [sqlite3]
    ;sqlite3.extension_dir =
    Может тут что нужно добавить?

    #5


    anbabai84,

    12 авг 2016


  6. denis01

    denis01
    Суперстар

    Команда форума
    Модератор

    С нами с:
    9 дек 2014
    Сообщения:
    12.236
    Симпатии:
    1.716
    Адрес:
    Молдова, г.Кишинёв

    Если выполнить phpinfo(); там что-то будет про sqlite?Попробуй у тебя же в папке php есть папка ext в ней уже php_pdo_sqlite.dll и php_sqlite3.dll?

    #6


    denis01,

    12 авг 2016


  7. bikerlex

    bikerlex
    Активный пользователь

    С нами с:
    2 дек 2014
    Сообщения:
    341
    Симпатии:
    40

    Тажа? А сервак перезапускаешь после изменений конфига? :)

    #7


    bikerlex,

    12 авг 2016


  8. Ganzal

    Ganzal
    Суперстар

    Команда форума
    Модератор

    С нами с:
    15 мар 2007
    Сообщения:
    9.901
    Симпатии:
    968

    А сервер перезапускается после правки конфигурации?

    #8


    Ganzal,

    12 авг 2016

(Вы должны войти или зарегистрироваться, чтобы разместить сообщение.)

Показать игнорируемое содержимое

Ваше имя или e-mail:
У Вас уже есть учётная запись?
  • Нет, зарегистрироваться сейчас.
  • Да, мой пароль:
  • Забыли пароль?

Запомнить меня

  • Remove From My Forums
  • Question

  • Hello,

    I get the following error when I run my web site:

    [25-Nov-2014 12:32:50 America/Los_Angeles] PHP Fatal error:  Class ‘SQLite3’ not found in D:homesitewwwrootutil.php on line 62

    How do I enable SQLite3 for Azure Websites?

    I did read the following article but I am not sure how to proceed.

    http://azure.microsoft.com/en-us/documentation/articles/web-sites-php-configure/

    Any ideas are appreciated.

    Edit:

    Ok, I found a solution:

    I downloaded the php_sqlite3.dll for the correct PHP version on http://windows.php.net/download/.

    Make sure to select the Non Thread Safe version.

    After that uploaded the file and added the following environment variable for the website.

    Not sure why this is needed because sqlite3 should be enabled by default in PHP 5.4…


    Best Regards, Simon de Kraa.

    • Edited by

      Wednesday, November 26, 2014 10:18 AM

Answers

  • Found a solution. See original answer.


    Best Regards, Simon de Kraa.

    • Marked as answer by
      Shirisha Paderu
      Wednesday, November 26, 2014 4:55 PM

171 votes

2 answers

Get the solution ↓↓↓

Any of the other questions are for Ubuntu only.

What I did:
In the php ini I uncommented this line: extension=sqlite3
as well as the one defining the extension_dir as ext

In PATH I added the PHP installation folder, which includes the libsqlite3.dll

«php -m» in a shell still does not show up sqlite3 (or anything similar) and any PHP file using SQLite3 results in the classic: «Fatal error: Uncaught Error: Class «SQLite3″ not found in [php file]»

All the tutorials online (the two for windows that google can find) just say it’s working after these steps (or even after the first).

2021-12-19

Write your answer


570

votes

Answer

Solution:

TL;DR: You have thephp_sqlite3.dll, right?

https://www.php.net/manual/en/sqlite3.installation.php

They state:

The SQLite3 extension is enabled by default.

and (this is the important part):

Windows users must enablephp_sqlite3.dll in order to use this extension. This DLL is included with Windows distributions of PHP.

and (you followed that already I guess)

Note: Additional setup on Windows as of PHP 7.4.0

In order for this extension to work, there are DLL files that must be
available to the Windows systemPATH. For information on how to do
this, see the FAQ entitled «How do I add my PHP directory to thePATH
on Windows». Although copying DLL files from the PHP folder into the
Windows system directory also works (because the system directory is
by default in the system’sPATH), this is not recommended. This
extension requires the following files to be in thePATH
:libsqlite3.dll.

Other idea:

  • Did you edit the correct php.ini? There might be several. Where is php.ini?


841

votes

Answer

Solution:

The problem is in how the default windows .ini files are named

By default, the .ini files provided are named «php.ini-production» and «php.ini-development». Since they don’t end with «.ini» they are not picked up and any edits ignored.

After renaming one to php.ini (and restarting) it finally worked.

In hindsight completely obvious but it just did not register with me for quite a while


Share solution ↓

Additional Information:

Date the issue was resolved:

2021-12-19

Link To Source

Link To Answer
People are also looking for solutions of the problem: call to a member function store() on null

Didn’t find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.


Similar questions

Find the answer in similar questions on our website.

  1. I am running on Windows 10

    [08:55:14] [Server thread/INFO]: Loading pocketmine.yml…
    [08:55:14] [Server thread/WARNING]: Debugging assertions are enabled, this may impact on performance. To disable them, set `zend.assertions = -1` in php.ini.
    [08:55:14] [Server thread/INFO]: Loading server properties…
    [08:55:14] [Server thread/INFO]: Selected English (eng) as the base language
    [08:55:14] [Server thread/INFO]: Starting Minecraft: PE server version v1.1.0.55
    [08:55:14] [Server thread/INFO]: Opening server on 0.0.0.0:19132
    [08:55:14] [Server thread/INFO]: This server is running PocketMine-MP version 1.7dev-8 «[REDACTED]» (API 3.0.0-ALPHA7)
    [08:55:14] [Server thread/INFO]: PocketMine-MP is distributed under the LGPL License
    [08:55:14] [Server thread/INFO]: Loading recipes…
    [08:55:14] [Server thread/INFO]: Loading resource packs…
    [08:55:14] [Server thread/INFO]: Loading essentialsTP v1.2.0-dev1
    [08:55:14] [Server thread/INFO]: Loading FactionsProBeta v1.4.5
    [08:55:14] [Server thread/INFO]: Preparing level «world»
    [08:55:14] [Server thread/INFO]: Enabling essentialsTP v1.2.0-dev1
    [08:55:14] [Server thread/INFO]: [essentialsTP] essentialsTP+ loading…
    [08:55:14] [Server thread/CRITICAL]: Error: «Class ‘SQLite3’ not found» (EXCEPTION) in «essentialsTP.phar/src/essentialsTP/essentialsTP» at line 1346
    [08:55:14] [Server thread/INFO]: Disabling essentialsTP v1.2.0-dev1
    [08:55:14] [Server thread/CRITICAL]: Error: «Call to a member function close() on null» (EXCEPTION) in «essentialsTP.phar/src/essentialsTP/essentialsTP» at line 1366
    [08:55:14] [Server thread/INFO]: Enabling FactionsProBeta v1.4.5
    [08:55:14] [Server thread/CRITICAL]: Error: «Class ‘SQLite3’ not found» (EXCEPTION) in «FactionsPro_1.4.phar/src/FactionsPro/FactionMain» at line 70
    [08:55:14] [Server thread/INFO]: Disabling FactionsProBeta v1.4.5
    [08:55:14] [Server thread/CRITICAL]: Error: «Call to a member function close() on null» (EXCEPTION) in «FactionsPro_1.4.phar/src/FactionsPro/FactionMain» at line 257
    [08:55:14] [Server thread/INFO]: Starting GS4 status listener
    [08:55:14] [Server thread/INFO]: Setting query port to 19132
    [08:55:14] [Server thread/INFO]: Query running on 0.0.0.0:19132
    [08:55:14] [Server thread/INFO]: Default game type: Survival Mode
    [08:55:14] [Server thread/INFO]: Done (0.237s)! For help, type «help» or «?»

  2. This error is definitely from your php.ini, please uncomment or enable the extensions for SQLite3 inside it.

  3. Where can I find php.ini?


  4. Awzaw

    Awzaw
    Zombie Pigman
    Poggit Admin

    In the same folder as your PHP binaries. Even though SQLite3 is included by default with PHP, on Windows it seems you have to manually add these entries to php.ini (or remove the semicolon if these lines start with a semicolon):

    extension=php_pdo.dll
    extension=php_sqlite3.dll

    Also see here

  5. I still don’t understand…What are the lines I should edit?

  6. You should just add the lines Awazaw posted on the bottom of the php.ini file. Did you find the file?

Share This Page

Понравилась статья? Поделить с друзьями:
  • Clash of clans на компьютер скачать windows 7 без bluestacks
  • Cisco any connection windows 10 не устанавливается
  • Clash of clans на компьютер скачать windows 7 64 bit
  • Cisco any connection windows 10 download
  • Clash of clans на компьютер скачать windows 10 torrent