sqlite php getting unrecognized token: ":" error while inserting and parameterized query sqlite php getting unrecognized token: ":" error while inserting and parameterized query sqlite sqlite

sqlite php getting unrecognized token: ":" error while inserting and parameterized query


@arnoldIf you are using PDO for that.

The way to prepare and execute your query would be as follows.

$dbObject = new PDO('sqlite:sqlitedb');// NEW LINE$articleInsertQuery = "INSERT INTO Articles VALUES (?, ?, ?, ?, ?)";$query = $dbObject->prepare($articleInsertQuery);$query->execute(array($i, $title, $content, $date, 93));

EDIT:

See sqlite3 prepare.

$articleInsertQuery = "INSERT INTO Articles VALUES (:i, :title, :content, :date, :int)";$query = $dbObject->prepare($articleInsertQuery);$query->bindValue(':i', $i, SQLITE3_INTEGER);$query->bindValue(':title', $title, SQLITE3_TEXT);$query->bindValue(':content', $content, SQLITE3_TEXT);$query->bindValue(':date', $date, SQLITE3_TEXT);$query->bindValue(':int', 93, SQLITE3_INTEGER);    $result = $query->execute();

Hope this helps.