<?php require 'INewsDB.class.php'; class NewsDB implements INewsDB{ protected $_db; const DB_NAME = '/var/www/mysite/news.db'; /** * */ function __construct(){ if(is_file(self::DB_NAME)){ $this->_db = new SQLite3(self::DB_NAME); }else{ $this->_db = new SQLite3(self::DB_NAME); $sql = "CREATE TABLE msgs( id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, category INTEGER, description TEXT, source TEXT, datetime INTEGER)"; $this->_db->exec($sql) or die($this->_db->lastErrorMsg()); $sql = "CREATE TABLE category( id INTEGER, name TEXT)"; $this->_db->exec($sql) or die($this->_db->lastErrorMsg()); $sql = "INSERT INTO category(id, name) SELECT 1 as id, 'Политика' as name UNION SELECT 2 as id, 'Культура' as name UNION SELECT 3 as id, 'Спорт' as name"; $this->_db->exec($sql) or die($this->_db->lastErrorMsg()); } } function __destruct(){ unset($this->_db); } function saveNews($title, $category, $description, $sourse){} function getNews(){} function deleteNews($id){} } $news = new NewsDB; interface INewsDB{ // другй файл function saveNews($title, $category, $description, $source); function getNews(); function deleteNews($id); 

Mistake:

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Located in the / var / www / mysite folder
mysite - 755, owner - I
ubuntu 14.10 desktop

PS The same problem arose with requests for MySQL with the same error, but I decided to score and try to do it through SQLlite, but, apparently, the problem did not dare.

  • one
    you have the wrong syntax insert - etki
  • The syntax is fine, except for; after the first 2 requests, but these are jokes already processing in linux, in the open server this will not happen, they helped me to solve the problem on stackoverflow.com/questions/29162508/… - Msim Yopt

1 answer 1

from the answer which is accepted by the author, with an addition from me:

it seems that the file /var/www/mysite/news.db not writable by the user on whose behalf the http server processes requests.

need one of the three (in descending order of intelligence):

  1. configure the http server to process your site on behalf of the user who owns /var/www/mysite/news.db .

  2. change the ownership of the file so that it is owned by the user, on whose behalf the http server processes requests:

     $ sudo chown пользователь /var/www/mysite/news.db 
  3. give the right to write to this file to everyone:

     $ chmod +w /var/www/mysite/news.db