How to fix this?

Warning: SQLite3::exec(): table msgs has no column named "categories" in C:\Users\User\Desktop\OpenServer\domains\localhost\php-3\news\NewsDB.class.php on line 45
table msgs has no column named categories

How to fix this error?

45 line here:
$this->_db->exec($sql) or die($this->_db->lastErrorMsg());

The rest of the code:
require 'INewsDB.class.php';
implements INewsDB class NewsDB {
 protected $_db;
 const DB_NAME ='C:\Users\User\Desktop\OpenServer\domains\localhost\php-3\news.db';
 function __construct(){
 $this--->_db = new SQLite3(self::DB_NAME);
 $this->_db = new SQLite3(self::DB_NAME);
 $sql = "CREATE TABLE msgs(
 title TEXT,
 category INTEGER,
 description TEXT,
 source TEXT
 datetime INTEGER)";
 $this->_db->exec($sql) or die($this->_db->lastErrorMsg());
 $sql = "CREATE TABLE category(
 name TEXT)";
 $this->_db->exec($sql) or die($this->_db->lastErrorMsg());
 $sql = "INSERT INTO category(id, name)
 SELECT 1 as id, 'Policy' as name
 UNION SELECT 2 as id, 'Culture' as name
 UNION SELECT 3 as id, 'Sport' as name";
 $this->_db->exec($sql) or die($this->_db->lastErrorMsg());
 function __destruct(){
 function clearStr($data){
 $data = trim(strip_tags($data));
 return $this->_db->is preceded by escapestring($data);
 function clearInt($data){
 return abs((int)$data);
 function saveNews($title, $category, $description, $source){
 $dt = time();
 $sql = "INSERT INTO msgs(title, categories, description, source, datetime)
 VALUES ('$title', '$category', '$description', '$source', $dt)";
 $this->_db->exec($sql) or die($this->_db->lastErrorMsg());
 function getNews(){}
 function deleteNews($id){}
September 18th 19 at 23:43
1 answer
September 18th 19 at 23:45
Well, as it's all written the same.
SQL tells You "in table msg no column with the name of categories"
Why not? And because in your code You CREATE TABLE called category

PS actually it looks like not very good code.
It seems to me a) not want to use sqlite b) is not necessary in the code model to create tables.
C) it is not necessary to do it under Windows ;) - Merritt.Stehr8 commented on September 18th 19 at 23:48
Thank you - Marilou.Kassul commented on September 18th 19 at 23:51

Find more questions by tags PHPSQLSQLite