views:

21

answers:

2

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


 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

group is an int, boxed is an int, the rest are strings. and id is an int.

+5  A: 

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

Mike Thomsen
and you can fix this by using `` around the column name. That's the character left of 1 on a querty keyboard.
SorcyCat
A: 

No, there is noway 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 annoying disadvantage of the prepared statements.

Col. Shrapnel