Answer the question
In order to leave comments, you need to log in
Where is the error in the database query?
<?php
$db = new SQLite3("test.db");
$sql = "CREATE TABLE таблица1(
id INTEGER PRIMARY KEY
столбец1 TEXT,
столбец2 TEXT
);";
$db->query($sql);
$sql = "INSERT INTO таблица1 ('папапп', 'кекекек') ;";
$db->query($sql);
$sql = "SELECT столбец1, столбец2 FROM таблица1 ;";
$result_array = $db->array_query($sql, SQLITE_ASSOC); //тут ошибка
print json_encode($result_array);
?>
Answer the question
In order to leave comments, you need to log in
Errors in SQL queries
$sql = "CREATE TABLE таблица1(
id INTEGER PRIMARY KEY,
col1 INT,
col2 TEXT
);";
$db->exec($sql);
$sql = "INSERT INTO таблица1(col1, col2) VALUES
('aaaa', 'bbbbb'),
('xxx', 'yyy');";
$db->exec($sql);
$sql = "SELECT * FROM таблица1;";
$result = $db->query($sql);
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
$array[] = $row;
}
print json_encode($array);
Well, let's play a guessing game.
In request
$sql = "INSERT INTO таблица1 ('папапп', 'кекекек') ;";
shouldn't it be VALUES? Although I could be wrong.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question