-1

嗨,当我使用以下 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

考虑到我已经逃脱了有问题的字符串,这对我来说毫无意义。甚至那些有问题的之前的字符串

4

1 回答 1

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'"
于 2013-07-30T22:45:28.567 回答