Quoting richardtoo...@paradise.net.nz: > Quoting "Bentley, Dain" <dbent...@nas.edu>: > > > Thanks for the help. I'm getting a different error now: > > SQLSTATE[HY000] [1] unable to open database: /path/to/db > > > > Can't seem to find much on this error. Something from the PHP website > > about > > having to recompile PHP from source but it's an old thread and I'd > > rather not > > use non-packaged third party tools if I can help it. > > > > And have you tried using the file from sqlite command line to check all > OK with > sqlite & the database file? > > $ sqlite /path/to/db >
Got to be something you've done - works fine here for me ... Built a 4.9 i386 box, installed same packages as you ... No need to build anything or configure anything. # cd /tmp/ # sqlite test.db SQLite version 2.8.17 Enter ".help" for instructions sqlite> CREATE TABLE apple (apple_id INTEGER); sqlite> INSERT INTO apple (apple_id) VALUES(44); sqlite> SELECT * FROM apple; 44 sqlite> # php test.php Array ( [apple_id] => 44 [0] => 44 ) # cat /tmp/test.php <?php try { $dbh=new PDO("sqlite2:/tmp/test.db"); } catch (PDOException $e) { print_r($e); } $res=$dbh->query("SELECT * FROM apple"); foreach ($res as $r) { print_r($r); } ?> HTH. > > > > ________________________________________ > > From: joshua stein [j...@openbsd.org] > > Sent: Tuesday, December 13, 2011 6:08 PM > > To: Bentley, Dain > > Subject: Re: PHP SQLite connection in OpenBSD > > > > > PDO drivers sqlite2 > > > > > > Here is the code I am using to attempt to connect > > > <?php > > > try { > > > // connect to SQLite from PDO database > > > $dbh = new PDO("sqlite:/bandwith/stats.db"); > > > > you have sqlite2 installed, but the "sqlite" pdo prefix is for > > sqlite 3 databases. > > > > try opening "sqlite2:/bandwith/stats.db".