Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 0 down vote accepted

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 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
share|improve this answer
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 posting your answer, you agree to the privacy policy and terms of service.

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