I’m trying to insert data into a certain table, which doesn’t work. Using the same code to insert into other tables work:
$sql = "INSERT INTO projects (name, desc) VALUES ('$name', '$desc')";
if($this->conn->query($sql) !== true)
{
echo(mysqli_error($this->model->conn));
}
When using it on the table I wish to insert data into (projects
), it informs me with the following:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'desc) VALUES ('das', 'das')' at line...
On the other hand, using the same code--modifying it a slight bit:
$sql = "INSERT INTO users (forename, surname) VALUES ('$name', '$desc')";
This successfully inserts $name
and $desc
into the users
table.
Both forename
and surname
in the users
table, have the same types as name
and desc
in the projects
table. The database is connected to in the “usual” way, using the object oriented version of PHP’s MySQL.
It would appear to me as though I’m not doing anything wrong. Perhaps someone has experienced something similar at some point and thus can point me in the right direction?