我一直使用普通查询将数据插入数据库,但现在我想用准备好的语句来实现。我已经在使用语句来选择我所有文件中的数据,但插入从来没有用过……现在我又没主意了。也许有人可以看出我做错了什么。
$animeId = $_POST['animeId'];
$username = $_POST['username'];
$rating = $_POST['rating'];
$story = $_POST['story'];
$genre = $_POST['genre'];
$animation = $_POST['animation'];
$characters = $_POST['characters'];
$music = $_POST['music'];
//Datum auslesen
$date = date("Y-m-d H:i:s");
if($insertRating = $con->prepare("INSERT INTO anime_rating (animeId, rating, story, genre, animation, characters, music, user, date) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?"))
{
$insertRating->bind_param("iiiiiiiss", $animeId, $rating, $story, $genre, $animation, $characters, $music, $username, $date);
$insertRating->execute();
$insertRating->close();
}
最佳答案
您的查询中有一个错误的逗号:
music, user,) VALUES (?, ?, ?, ?, ?, ?, ?
^^^
HERE
应该是
music, user) VALUES (?, ?, ?, ?, ?, ?, ?
关于php - 插入语句不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22212992/