MySQLi query in PHP isn't working right, 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.
No, there is no way to get the query after MySQLi prepares it, because there is no query in the usual sense. The string goes to the server as you wrote it - with question marks. That's an annoying disadvantage of the prepared statements.
精彩评论