PHP Fatal error: Uncaught Error: Class 'SQLite3' not found in / var / www / html /

0

I have the supposedly simple code below. The intuit is to create a table include values and soon after show the information, but in log apache is showing the following:

[:error] [pid 17622] [client 10.1.21.1:42895] PHP Fatal error:  Uncaught Error: Class 'SQLite3' not found in /var/www/html/acesso.php:2\nStack trace:\n#0 {main}\n  thrown in /var/www/html/acesso.php on line 2
<?php   
  $db = new SQLite3('test.db');

  $db->exec('CREATE TABLE test (id INT, message STRING)');

  $db->exec("INSERT INTO test (id, message) VALUES ('1', 'test message')");
  $db->exec("INSERT INTO test (id, message) VALUES ('2', 'test message 2')");

  $results = $db->query("SELECT * FROM test WHERE ID = 2");

  print_r($results->fetchArray());

?>
  

PHP Summer: 7.0

     

OS version: Ubuntu 16.10

     

Installed Sqlite Version: 3.14.1

     

Apache Version: Apache / 2.4.18 (Ubuntu)

    
asked by anonymous 14.03.2017 / 16:47

2 answers

1

Have you activated the sqlite3 module in Ubuntu's PHP7?

To activate, just go to the server and type in the console:

sudo apt-get update
sudo apt-get install php7.0-sqlite3

See if it solves, if it does not check Apache modules, in Ubuntu it has the command a2enmod that you can use to activate modules.

    
14.03.2017 / 19:38
0

There you are saying that you are not finding the SQLite3 class. You can use an include_once (class_file) to test

    
14.03.2017 / 17:43