pdo sqlite could not find driver... php file not processing
Asked Answered
K

6

27

Hi i'm received the could not find driver error when trying to connect to sqlite via a php file. I've set permission to 777... PHP Version 5.2.16, i have the module install. any reason why its not finding the driver, also php.ini is showing the extension pdo.so and pdo_mysql.so installed.

PDO

PDO support enabled PDO drivers mysql

pdo_mysql

PDO Driver for MySQL, client library version 5.0.92

try {
    // Connect to the SQLite Database.
    $db = new PDO('sqlite:.subscribers.db');
} catch(Exception $e) {
    die('connection_unsuccessful: ' . $e->getMessage());
}
Kura answered 10/1, 2012 at 13:6 Comment(2)
http://www.php.net/manual/en/ref.pdo-sqlite.phpAbed
On Windows, the only thing that helped me was to add "C:\Program Files\php" to the system PATH environment variables, although I cannot imagine why.Howlend
H
27

You need

[PDO_SQLITE]
extension=pdo_sqlite.so

to be enabled, for sqlite:.subscribers.db

or, for Windows:

[PHP_PDO_SQLITE]
extension=php_pdo_sqlite.dll

And of course this extension in your ext directory.

Hermaphroditism answered 10/1, 2012 at 13:11 Comment(5)
do i have to recompile php to get the pdo_sqlite.so extension?Kura
no, just add *.so file to ext dir, add few lines in php.ini and that's allHermaphroditism
ok i figured it out sudo pecl install pdo_sqlite did the trick i did pdo_mysql earlier sqlite did the trick.Kura
Also, on ubuntu: #8822709Vanderhoek
I have edited /etc/php5/apache2/php.ini then i have restarted Apache (sudo service apache2 restart)Furuncle
J
39

I had to actually install the extension, and this is how i did on Ubuntu 16 running PHP 7.1:

sudo apt install php7.1-sqlite3

Januarius answered 13/4, 2017 at 1:47 Comment(3)
sudo apt-get install php5-sqlite for php5 on Ubuntu server 14.04.5 LTSGreenberg
or sudo apt install php-sqlite3 for all variations of php7Clupeoid
sudo apt install php8.0-sqlite3 if you use PHP 8.Damsel
H
27

You need

[PDO_SQLITE]
extension=pdo_sqlite.so

to be enabled, for sqlite:.subscribers.db

or, for Windows:

[PHP_PDO_SQLITE]
extension=php_pdo_sqlite.dll

And of course this extension in your ext directory.

Hermaphroditism answered 10/1, 2012 at 13:11 Comment(5)
do i have to recompile php to get the pdo_sqlite.so extension?Kura
no, just add *.so file to ext dir, add few lines in php.ini and that's allHermaphroditism
ok i figured it out sudo pecl install pdo_sqlite did the trick i did pdo_mysql earlier sqlite did the trick.Kura
Also, on ubuntu: #8822709Vanderhoek
I have edited /etc/php5/apache2/php.ini then i have restarted Apache (sudo service apache2 restart)Furuncle
L
12

On archlinux i had to do two things:

first install php-sqlite

pacman -S php-sqlite

after that in my php.ini file for me in /etc/php/php.ini i had to uncomment this line:

;extension=pdo_sqlite.so

by removing semicolon.

Dont forget to restart server.

Lantha answered 15/5, 2017 at 18:46 Comment(1)
Works perfectly for me! Thx. I just uncomment ;extension=pdo_sqlite.so as you said.Clegg
D
3

I am using a portable version of PHP on windows, using the inbuilt web server. I found the following steps helped:

  1. Renaming php.ini-development to php.ini
  2. Uncommenting extension_dir = "ext" under [PHP] (around line 700)
  3. making sure the following lines are in the php.ini:
[sqlite3]    
sqlite3.extension_dir = "ext"    
extension = sqlite3    
extension = pdo_sqlite
  1. Running the php webserver with the following flag added on: - c C:\Path\to\PortablePHP\php.ini

So currently my php command is php -S localhost:8081 -c B:\Downloads\php-7.2.6\php.ini.

Dorsoventral answered 2/6, 2018 at 20:45 Comment(0)
C
1

Debian 11 (bullseye) provides php7.4-sqlite3:

apt install php7.4-sqlite3
Cankerworm answered 10/1, 2023 at 8:43 Comment(0)
S
0

DB_CONNECTION=sqlite3 worked for me

Selfconceit answered 30/3 at 11:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.