-2

I have not tried the following code with some success without PDO:

 <html><body>
    <?php
    $db = new sqlite3('/home/harry/interface/wildlife.db');
    
    $results = $db->query('SELECT cascade FROM animalStream');
    while ($row = $results->fetchArray()) {
        var_dump($row);
    }
    ?>
    </body></html>

It shows relevent data without throwing errors, but the format is like this:

 string(9) "otter.xls" ["cascade"]=> string(9) "otter.xls" } array(2) { [0]=> string(11) "primate.xls" ["cascade"]=> string(11) "primate.xls" } array(2) { [0]=> string(13) "junglecat.xls" ["cascade"]=> string(13) "junglecat.xls" } array(2) { [0]=> string(12) "pangalin.xls" ["cascade"]=> string(12) "pangalin.xls" }

So it wants to work, it is just getting it to format correctly. Does any one have any ideas about that? Thank you!

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
  • [How do I get PHP errors to display?](https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display?rq=1) Is the SQLite3 extension enabled? – brombeer Jan 13 '22 at 10:13
  • Thanks for your comment. No, I have not enabled the SQLite3 extension. I am checking on that now. I am using lighttpd as a server. – Harry Hobson Jan 13 '22 at 10:22
  • I have modified the php.ini file by un-commenting the following two lines: extension=pdo_sqlite.so extension=sqlite.so But no joy yet. – Harry Hobson Jan 13 '22 at 11:10
  • Restarted your server? Does the extension show as enabled in `phpinfo()`? – brombeer Jan 13 '22 at 11:19
  • No, it does not show up as enabled or disabled. Just shows the author's names. This is in the php.ini file: [sqlite3] ; Directory pointing to SQLite3 extensions ; http://php.net/sqlite3.extension-dir ;sqlite3.extension_dir = Trying to find an explanation for it. – Harry Hobson Jan 13 '22 at 11:45
  • I am unclear as to what is suppose to go here: sqlite3.extension_dir = "" Sqlite is showing up all over my phpinfo.php, but still getting a blank page. – Harry Hobson Jan 13 '22 at 13:53
  • Fatal error: Uncaught PDOException: PDO::__construct(): Argument #1 ($dsn) must be a valid data source name in /var/www/html/index.php:8 Stack trace: #0 /var/www/html/index.php(8): PDO->__construct() #1 {main} thrown in /var/www/html/index.php on line 8 – Harry Hobson Jan 13 '22 at 16:00
  • It seems to work now. I replaced /var_dump($row); with $row=(implode(",", $row)); and it works. It produces two comma delimited outputs per line, otter.xls,otter.xls , but that can be dealt with. – Harry Hobson Jan 14 '22 at 01:31

1 Answers1

0

It seems to work now. I replaced /var_dump($row); with $row=(implode(",", $row)); and it works. It produces two comma delimited outputs per line, otter.xls,otter.xls , but that can be dealt with.