PHP mysqli编写的UPDATE语句插入错误的值

时间:2016-10-22 23:36:02

标签: php mysql

我真的希望我不会错过这里明显的东西,所有参数订单对我来说都很好,但名称值在描述时更新为0价值没有触及。

功能:

public function doEdit ($user_id, $conn, $list_name, $list_desc, $list_id) {

   echo "user id: " . $user_id . ", list id: " . $list_id 
       . ", list name: " . $list_name . ", list desc: " . $list_desc;

   if (!($stmt = $conn->prepare("UPDATE collection.user_list SET name = ? 
          AND description = ? WHERE user_id = ? AND list_id = ?"))) {
      echo "Prepare failed: " . $mysqli->error;
   }
   if (!($stmt->bind_param('ssii', $list_name, $list_desc, $user_id, 
          $list_id))) {
      echo "Bind failed: " . $stmt->error;
   }
   if (!($stmt->execute())) {
      echo "Execute failed: " . $stmt->error;
   }
 }

电话:

if ($req == "PUT") {
   parse_str(file_get_contents("php://input"), $_PUT);
   $this->doEdit($user_id, $conn, $_PUT['Name'], $_PUT['Description'],
           $_PUT['ListID']);
}

我没有收到任何失败通知,并且在变量echo给出的结果中 user id: 1, list id: 9, list name: edited name, list desc: edited description

但db行改为:

user_id, list_id, name, description
'1', '9', 'hello', 'world'

为:

user_id, list_id, name, description
'1', '9', '0', 'world'

我错过了什么/弄乱了什么?

0 个答案:

没有答案