This question already has an answer here:
I am trying to execute an INSERT INTO query but for some reason an error is thrown.
$result1 = mysqli_query($connection,
"INSERT INTO `results`
(`result_quiz_name`, `result_marks`, `result_grade`,
`student_id`, `result_max_marks`)
VALUES ('Ionic Bonding Introduction', $marks, $grade,
$student, 5)");
The variable $marks
is an integer, the $grade
variable is a string and the $student
variable is just the integer value of a session variable. The error that is displayed is this:
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 1, 5)' at line 1
I just can't seem to work out where the syntax error is. I have run this query in phpMyAdmin and it works fine (obviously substituting the variables for values).
Thanks,
</div>