简体   繁体   English

500内部服务器错误与SQLite PHP

[英]500 Internal Server Error with SQLite PHP

I'm just following a tutorial of sqlite with php to create a data entry application. 我只是在用SQL编写sqlite教程来创建数据输入应用程序。 And I got an error 500 Internal Server Error with this simple line of code. 通过此简单的代码行,我收到了一个错误500 Internal Server Error。

<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'); 当我在下面的行中注释//$database = new SQLite3('db.sqlite'); the error disappears. 错误消失。 How can I use SQLite3 with my Php? 如何在PHP中使用SQLite3?

I believe you need to install the support to PHP. 我相信您需要将支持安装到PHP。

If you are using php5 try this: sudo apt-get install php5-sqlite3 如果您使用的是php5,请尝试以下操作: sudo apt-get install php5-sqlite3

If you are using php7 try this: sudo apt-get install php7.0-sqlite3 如果您使用的是php7,请尝试以下操作: 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? 启用错误消息传递也可以为您提供帮助: http : //www.php.net/manual/pt_BR/function.error-reporting.php 如何显示PHP错误?

The 500 Internal Service Error was fixed after I included : 我添加以下内容后,修复了500内部服务错误:

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 我可以通过使用PHP7而不是PHP5来解决它,为Php7配置nginx并为Php7安装sqlite模块

sudo apt-get install php-sqlite3

or 要么

sudo apt-get install sqlite3 libsqlite3-dev

then check php-sqlite3 然后检查php-sqlite3

sudo apt-cache search php-sqlite3 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM