I have PHP 5.4.16 running on my Centos7 server with SQLite3 3.7.17. I am able to use python to write to the database and create the database, but when I try to use PHP to read it in on my website I cannot do anything with SQLite3.
<?php
$db = new SQLite3('var/www/html/WebDatabase/AccountDevices.db');
$result = $db->query('SELECT * FROM log');
var_dump($result->fetchArray());
?>
As you can see my code is basic so I don't think that is the issue, it's just php isn't playing nice with SQLite3.
My current php.ini file:
[sqlite]
http://php.net/sqlite.assoc-case
;sqlite.assoc_case = 0
[sqlite3]
sqlite3.extension_dir=/usr/bin/sqlite3
I was getting an error that was in the ballpark of SQLite is not installed, then I installed php-pdo but was unable to get that to work either. php -m
[PHP Modules]
bz2
calendar
Core
ctype
curl
date
ereg
exif
fileinfo
filter
ftp
gettext
gmp
hash
iconv
json
libxml
mhash
mysql
mysqli
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
sqlite3
standard
tokenizer
xml
zip
zlib
[Zend Modules]
So SQLite3 is on and so is that PDO thing(I don't know what this is.)
What am I messing up here? I have been at it for about 4 hours trying a bunch of stuff to work this out. I have gotten to this error now.
PHP Fatal error: Uncaught exception 'PDOException' with message 'invalid data source name' in /var/www/html/accounts.php:3
Stack trace:
#0 /var/www/html/accounts.php(3): PDO->__construct('var/www/html/We...')
#1 {main}
thrown in /var/www/html/accounts.php on line 3
Wot do?
Edit:
PHP Fatal error: Uncaught exception 'PDOException' with message 'invalid data source name' in /var/www/html/accounts.php:3
Stack trace:
#0 /var/www/html/accounts.php(3): PDO->__construct('var/www/html/We...')
#1 {main}
thrown in /var/www/html/accounts.php on line 3
error when
$db = new PDO('var/www/html/WebDatabase/AccountDevices.db');
is being used.