doure8758 2014-11-20 04:49
浏览 29

mysqli和准备好的陈述

I cannot see to find the problem in this php code:

if ($stmt = $mysqli->prepare("INSERT INTO Champions(Spell 1) VALUES(?)")) {
            $stmt->bind_param('s', $SP1);
            $stmt->execute();
            $stmt->close();
        }
        else {
            printf("Errormessage: %s
", $mysqli->error);
        }
}

Just throws the 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) VALUES (?)' at line 1

  • 写回答

1条回答 默认 最新

  • duanchuonong5370 2014-11-20 04:50
    关注

    CAUSE YOU HAVE SPACE IN FIELD NAME

    Spell 1
    

    try with proper fieldname

    INSERT INTO Champions(Spell 1) VALUES(?)
                               ^
    

    or use quoting(not tried)

    INSERT INTO Champions(`Spell 1`) VALUES(?)
    
    评论

报告相同问题?