I am in debian7.
<?php
echo "creating a databse
";
try {
$dbh=new PDO('sqlite:voting.db');
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->exec('
CREATE TABLE tally(
QID varchar(32) NOT NULL,
AID integer NOT NULL,
votes integer NOT NULL,
PRIMARY KEY(QID,AID)
)');
} catch (Exception $e) {
echo "error!!:$e";
exit;
}
echo "db created successfully!";
?>
I want to create my sqlite db voting.db
with the code,it ran accross error info:
creating a databse error!!:exception 'PDOException' with message 'could not find driver' in /var/www/sqlite1.php:4
Stack trace: #0 /var/www/sqlite1.php(4):
PDO->__construct('sqlite:voting.d...') #1 {main}
How to fix it?
You do not have the PDO sqlite extension, because it is not installed and/or because it is not enabled.
On ArchLinux:
su
pacman -S php-sqlite
sed -i 's|.*\(extension.*pdo.*sqlite.*\)|\1|' /etc/php/php.ini
On Debian you should perform similar steps. I think the following command should be enough:
su -c 'apt-get install php5-sqlite'