0

I'm just following a tutorial of sqlite with php to create a data entry application. And I got an error 500 Internal Server Error with this simple line of code.

<h1><center>Create a DB in the same folder<br></center></h1>

<?php
        $database = new SQLite3('db.sqlite');
?>

When I comment down the line //$database = new SQLite3('db.sqlite'); the error disappears. How can I use SQLite3 with my Php?

Philipp Maurer
  • 2,480
  • 6
  • 18
  • 25

2 Answers2

1

The 500 Internal Service Error was fixed after I included :

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

And the new error appeared:

Fatal error: Class 'SQLite3' not found in /var/www/html/php/index.php on line 8

I was able to fixed it by using PHP7 instead of PHP5, config nginx for the Php7 and install sqlite modules for Php7

sudo apt-get install php-sqlite3

or

sudo apt-get install sqlite3 libsqlite3-dev

then check php-sqlite3

sudo apt-cache search php-sqlite3 
0

I believe you need to install the support to PHP.

If you are using php5 try this: sudo apt-get install php5-sqlite3

If you are using php7 try this: sudo apt-get install php7.0-sqlite3

Enabling error messaging can help you too: http://www.php.net/manual/pt_BR/function.error-reporting.php How do I get PHP errors to display?

feedMe
  • 3,431
  • 2
  • 36
  • 61