1

With the reference of the bellow link,I was tried to connect with an sqlite database using PHP.

How do I connect to an SQLite database with PHP?

<?php
$dir = 'sqlite:/var/www/html/shijin/brandz_db';
$dbh  = new PDO($dir) or die("cannot open the database");

But i am getting the following error,

Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in /var/www/html/shijin/sqlite.php:3 Stack trace: #0 /var/www/html/shijin/sqlite.php(3): PDO->__construct('sqlite:/var/www...') #1 {main} thrown in /var/www/html/shijin/sqlite.php on line 3

1 Answer 1

1

You need to install the PDO sqlite driver. Try

sudo pecl install pdo
sudo pecl install pdo_sqlite
Sign up to request clarification or add additional context in comments.

4 Comments

I am using ubuntu,getting error sudo: pecl: command not found
Then I guess sudo apt-get install php5-sqlite3 should do :P
@techouse I have tried ,but Unable to locate package php5-sqlite3
According to php.net/manual/en/ref.pdo-sqlite.php pecl have to be used on PHP >= 5.4 so depending on version you might have to first install pecl and try installing if from there if suggestion from @techouse didn't work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.