I have a fresh install of fedora 12 and am trying to get php and sqlite working I installed php through: yum install php php-devel php-pdo and restarted apache. Php pages are working just fine but whenever I try to load a page that uses sqlite the page is not processed and returns blank with non of the php code being processed. The page that i am using to test sqlite is:

// set path of database file
$db = $_SERVER['DOCUMENT_ROOT']."/../library.db";

// open database file
$handle = sqlite_open($db) or die("Could not open database");

// generate query string
$query = "SELECT * FROM books";

// execute query
$result = sqlite_query($handle, $query) or die("Error in query: ".sqlite_error_string(sqlite_last_error($handle)));

// if rows exist
if (sqlite_num_rows($result) > 0) {
    // get each row as an array
    // print values
    echo "<table cellpadding=10 border=1>";
    while($row = sqlite_fetch_array($result)) {
        echo "<tr>";
        echo "<td>".$row[0]."</td>";
        echo "<td>".$row[1]."</td>";
        echo "<td>".$row[2]."</td>";
        echo "</tr>";
    echo "</table>";

// all done
// close database file

The body and html tags are returned but non of the php is rendered. My question is how does one set up php with sqlite. Does one have to recompile, is their an rpm? I am looking for a step by step way of enabling sqlite for php. Thanks


See the answers to this same question that you asked earlier today.

One user mentioned just needing to install the latest version of php-pdo (yum install php-pdo) to enable support. That should probably be a good place to start for most users but it looks like you have already done that.

It could be because of the SQLite functions I was using in PHP, but that did not work for me on Fedora 13, so my experience involved recompiling PHP from source with sqlite support (to my knowledge it was not built into Fedora Core 4 and later versions). I had to download the source for PHP from http://php.net/downloads.php and compile it with support for the SQLite module.

tar xfvj php-5.3.2.tar.bz2 
cd php-5.3.2/ext/sqlite/
make install
/etc/init.d/httpd restart
  • I downloaded the source code and ran the commands you listed and a simple sqlite test : check 1 <?php echo "check 2"; if ($db = sqlite_open('my_sqlite_db', 0666, $sqlite_error)) { echo "check 3"; } else { die ($sqlite_error); echo "check 4"; } echo "check 5"; ?> , and only the first two checks print. any ideas? – jcb344 Jul 16 '10 at 22:35
  • The script should work fine. But if that does not work you could use php-pdo as suggested by another user on your other post. Connect using $db = new PDO('sqlite:/tmp/foo.db'); instead of with sqlite_open. In most cases that will work. Only in some cases (PEAR DB for example) does the pdo functions not work. – runlevelsix Jul 17 '10 at 23:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.