您好,我在使用follow sql时无法更新我的mysql表:
if(isset($_POST['submitFeedback'])){
$error = array();
$success = array();
$url = $_SERVER['HTTP_REFERER'];
$id = mysql_real_escape_string($_POST['ad_id']);
$email = mysql_real_escape_string($_GET['email']);
$voted = '1';
if(!isset($_POST['userFeedback'])){
$error[] = 'Please select some feedback';
}else{
if(isset($_POST['subComment'])){
$comment = strtolower(mysql_real_escape_string($_POST['userFeedback']));
$subComment = strtolower(mysql_real_escape_string($_POST['subComment']));
$insertIntoBuyerFeedback = mysql_query("UPDATE buyer_feedback SET
seller_vote='$voted', seller_comment='$comment',
seller_sub_comment='$subComment',
WHERE ad_id='$id' AND buyer_email='$email'") or die(mysql_error());
$success[] = 'Thank you for your feedback!';
}
}
}
我从浏览器中收到以下错误
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 'WHERE ad_id='5' AND buyer_email='test@test.com'' at line 1
考虑到我已经逃脱了有问题的字符串,这对我来说毫无意义。甚至是那些有问题的人之前的字符串
答案 0 :(得分:3)
在上一个更新列(seller_sub_comment)之后删除额外的逗号。
"UPDATE buyer_feedback
SET seller_vote='$voted',seller_comment='$comment',seller_sub_comment='$subComment'
WHERE ad_id='$id' AND buyer_email='$email'"