Answer the question
In order to leave comments, you need to log in
I don’t understand why the PHP code for adding a query to SQLite3 does not work?
Help, I'm really confused. I started to study OOP in PHP, I wrote such an elementary code and I don’t understand why it doesn’t work.
$title = "Item1";
$category = 1;
$description = "Item2";
$source = "Item3";
$db = new SQLite3('DB.sqlite3');
$sql = "CREATE TABLE msgs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT,
category INTEGER,
description TEXT,
source TEXT
) ";
$db->exec($sql);
unset($db);
$sql_insert = "INSERT INTO msgs (
title,
category,
description,
source )
VALUES (
$title,
$category,
$description,
$source
)";
$db = new SQLite3('DB.sqlite3');
$db->exec($sql_insert);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question