Windows fatal error uncaught error class sqlite3 not found in

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,4059 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

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

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

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

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

Не получается настроить 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:
У Вас уже есть учётная запись?
  • Нет, зарегистрироваться сейчас.
  • Да, мой пароль:
  • Забыли пароль?

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

Class SQLiteDatabase is an object from sqlite library, which support was dropped in PHP 5.4, but on various systems and configuration could be disabled in an earlier releases, as this library was long time marked as going to be deprecated.

Library php_sqlite.dll (Windows) or php_sqlite.so (Linux) is no longer supported in newer versions of PHP and was replaced with php_sqlite3.dll or php_sqlite3.so respectively.

You can:

  1. Try to find php_sqlite.dll (php_sqlite.so) somewhere in the Internet. Links like this or this may be helpful for you. However, you’ll have to carefully match old SQLite library file to your PHP’s platform (x64 or x86), build engine (VC6, VC9 or VC11), version (5.x) and type (TS for thread safe or NTS for non-thread safe). This might be a hard task.

  2. Leave php_sqlite.dll (SQLiteDatabase) behind and ship toward new php_sqlite3.dll (SQLite3 object). You have to first use a tool like SQLite Studio to convert your database file from 2.1 to 3.0 (size can be lowered by even a half) and then carefully compare SQLite and SQLite3 PHP manual pages to change necessary objects and functions call.

If option two, note that this shouldn’t be a hard work, as changes aren’t that big. For example, what I’ve learned so far:

  • SQLiteDatabase -> SQLite3,
  • SQLiteDatabase::unbufferedQuery -> SQLite3::query,
  • SQLiteResult::fetchAll(SQLITE_*) -> SQLite3Result::fetchArray(SQLITE3_*) etc.

As for fetching, in old SQLite we had:

$rowsIMEI = $db->unbufferedQuery($imeiSQL)->fetchAll(SQLITE_ASSOC);

foreach($rowsIMEI as $r)
{
    ...
}

While, in new SQLite3 we should:

$rowsIMEI = $db->query($imeiSQL);

while($r = $rowsIMEI->fetchArray(SQLITE3_ASSOC))
{
    ...
}

Other changes requires similar amount of work, so this shouldn’t be a life-time process.

I, of course, strongly advice anyone to go forward and choose second option. Progress is in most cases the better one of two available options.

738 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


261

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?


804

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: a non-numeric value encountered in

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.

Понравилась статья? Поделить с друзьями:
  • Windows fast mode при загрузке как убрать
  • Windows failed to start что это
  • Windows failed to start при установке с флешки ноутбук
  • Windows embedded compact ce core скачать бесплатно
  • Windows failed to start при установке с флешки 0xc0000359