由于SQL注入,我正在将MySQL语句重写为准备好的语句,但我无法使其工作。它返回:
错误:1 您的SQL语法有错误;查看与您的MariaDB服务器版本对应的手册,以便在#1;'附近使用正确的语法。在第1行
$cihc = mysqli_prepare($conn,"UPDATE user SET picture=? WHERE id1=?");
mysqli_stmt_bind_param($cihc, "si", $image, $userid);
$sql = mysqli_stmt_execute($cihc);
mysqli_stmt_close($cihc);
if ($conn->query($sql) === TRUE) {
echo "Sent successfully";
}
else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
答案 0 :(得分:0)
您正尝试对update
的结果执行查询。删除query()
调用并更改$sql
分配,因为它实际上不是SQL。
$cihc = mysqli_prepare($conn,"UPDATE user SET picture=? WHERE id1=?");
mysqli_stmt_bind_param($cihc, "si", $image, $userid);
$result = mysqli_stmt_execute($cihc);
mysqli_stmt_close($cihc);
if ($result) {
echo "Sent successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}