Tuesday 4 September 2018

The MySQL query in PHP does not work correctly, is there a way to get the exact query?

Is there a way to get the query after MySQLi prepares it? My query is messing up:

$query = "UPDATE event SET group=?, boxed=?, name=?, location=?, time=?, day=?, type=? WHERE id=? LIMIT 1";
if($stmt = $db -> prepare($query))
{
    $stmt -> bind_param("iisssssi", $group, $boxed, $name, $location, $time, $day, $etype, $id);
    $stmt -> execute();
    $stmt -> close();
}
else

Error message:
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 'group=?, boxed=?, name=?, location=?, time=?, day=?, type=? WHERE id=? LIMIT 1' at line 1
Variable group is an int, boxed is an int, the rest are strings, and id is an int.

You're using the SQL reserved word "group" as one of the column names.

0 comments:

Post a Comment