我试图根据查找' mentor_id'的行来更新表格。和' feedbacker_id'匹配变量输入。我正在使用声明:
/* create a prepared statement */
if ($stmt = mysqli_prepare($mysqli, "UPDATE feedback SET (last_updated=?, p2q1=?, p2q2=?, p2q3=?, p2q4=?)
WHERE mentor_id=? AND feedbacker_id=?")) {
/* bind parameters for markers */
mysqli_stmt_bind_param($stmt, "sssssss", $time,$p2q1,$p2q2,$p2q3,$p2q4,$mentor_id,$feedbacker_id);
/* execute query */
mysqli_stmt_execute($stmt);
/* close statement */
mysqli_stmt_close($stmt);
}
我在MySQLI语句之前测试了每个变量,以检查它们是否包含信息和do。我没有在PHP页面上收到任何反馈(没有错误),表格中的行没有更新。任何人都可以帮忙解决这个问题吗?
感谢您的建议。我收到了错误:
"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 '(last_updated=?, p1q1=?, p1q2=?, p1q3=?, p1q4=?) WHERE mentor_id=? AND feedba' at line 1"
我在语法中没有看到任何明显的错误?
根据@ gerald-schneider的建议修正:
/* create a prepared statement */
if ($stmt = mysqli_prepare($mysqli, "UPDATE feedback SET last_updated=?, p2q1=?, p2q2=?, p2q3=?, p2q4=? WHERE mentor_id=? AND feedbacker_id=?")) {
/* bind parameters for markers */
/* Bind parameters. Types: s = string, i = integer, d = double, b = blob */
mysqli_stmt_bind_param($stmt, "sssssss", $time, $p2q1, $p2q2, $p2q3, $p2q4, $mentor_id, $feedbacker_id);
/* execute query */
mysqli_stmt_execute($stmt);
/* close statement */
mysqli_stmt_close($stmt);
}