-1

I have PHP 5.6 installed on windows 7 and I used the built in server to run websites locally for testing. I want to connect to a Sqlite3 file and I've uncommented the appropriate lines in the php.ini file in my C:\Program Files\php folder. I still get this error when trying to view the page on my local server:

Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in C:\Users\USERX\Documents\pageloadbasic.php:13 Stack trace: #0

C:\Users\USERX\Documents\pageloadbasic.php(13): PDO->__construct('sqlite:db/lhblo...') #1 {main} thrown in C:\Users\USERX\Documents\pageloadbasic.php on line 13

Why do I get this error?

A couple of notes: my phpinfo file shows:

Configuration File (php.ini) Path C:\Windows(for some reason this always defaults to C:\Windows even if there is not php.ini file in there)

Loaded Configuration File C:\Program Files\php\php.ini

But there is no php.ini file in C:\Windows. Also, my php folder does not include a php_pdo.dll in the ext folder, but I added one that I extracted from the pecl-5.0.5-Win32 archive as instructed in some other sites.

I added extension=php_pdo.dll in my php.ini file.

I uncommented extension=php_pdo_sqlite.dll.

I uncommented extension=php_sqlite3.dll.

I have these two lines in my php.ini which related to sqlite:

[sqlite] ; http://php.net/sqlite.assoc-case ;sqlite.assoc_case = 0 (I did not change anything on these two lines because I'm not sure what it is for...)

[sqlite3] sqlite3.extension_dir = "ext" (on this line I added the "ext" directory as suggested on another post)

I have this in my php code to connect to my db file using pdo:
$db = new PDO('sqlite:db/xxxxx.db');

What am I missing? What do I need to do to get PDO to work with Sqlite3?

Fabio Cardoso
  • 1,181
  • 1
  • 14
  • 37
mo_maat
  • 2,110
  • 12
  • 44
  • 72
  • Do those extension DLLs actually exist? Are they in the right place? Are they the right version? Turn you error_reporting up in `php.ini` [not using `ini_set` in your script] and you should see the error messages if you're having any of these problems. – Sammitch Aug 14 '15 at 00:29
  • Yes, I checked and all those dlls exist in ext. My error reporting is on too. – mo_maat Aug 14 '15 at 02:30

1 Answers1

0

Problem solved. Even though I had properly uncommented all my dlls, and uncommented the sqlite3.extension_dir = "ext", you need to specifically uncomment the windows ext location on the line following ; On windows:' extension_dir = "ext"` And then restart your server.

mo_maat
  • 2,110
  • 12
  • 44
  • 72