sql update query没有执行但没有返回错误

时间:2014-09-19 09:56:19

标签: mysql sql mysqli

$id = 1; //temp

$promoTitle = trim($_POST['promoTitle']);
$imageURL = trim($_POST['imageURL']);
$affLink = trim($_POST['affLink']);
$couponCode = trim($_POST['couponCode']);

$stmt = $db->prepare('UPDATE dashboard SET promoTitle=?, image=?, url=?, couponCode=? WHERE id=?');

$q = $stmt->bind_param('ssssi', $promoTitle, $imageURL, $affLink, $couponCode, $id);

if($result = $db->query($q)){
    echo "updated";
}else{
    echo mysql_errno();
}

坚持了半个小时仍然无法#39;找出错误的是什么。我没有回复错误。我的表格如下http://i.imgur.com/snwloav.png

2 个答案:

答案 0 :(得分:0)

你可以在php中使用它来更新mysql

如果(isset($ _ POST [ '提交'])){     尝试{

         $id = 1; //temp

        $promoTitle = trim($_POST['promoTitle']);
        $imageURL = trim($_POST['imageURL']);
        $affLink = trim($_POST['affLink']);
        $couponCode = trim($_POST['couponCode']);

        $stmt = $db->prepare('UPDATE  dashboard  SET promoTitle = :promoTitle, image = :image, url  = :url, couponCode=:couponCode WHERE id =:id');
        $stmt->execute(array(
          ':promoTitle' => $promoTitle,
          ':image' => $image,
          ':url' => $url,
          ':couponCode' => $couponCode,             
          ':id' =>$id                        
        ));

    //redirect to Your page page
   header('Location: page.php?action=updated');
   exit;
  }

  catch(PDOException $e) {
      echo $e->getMessage();
  }

}

答案 1 :(得分:0)

$sql = "UPDATE Applicant SET phone_number=?, street_name=?, city=?, county=?, zip_code=?, day_date=?, month_date=?, year_date=? WHERE account_id=?";

$stmt = $db_usag->prepare($sql);

$stmt->bind_param('sssssdddd', $phone_number, $street_name, $city, $county, $zip_code,     $day_date, $month_date, $year_date, $account_id);
$stmt->execute();

if ($stmt->errno) {
  echo "FAILURE!!! " . $stmt->error;
}
else echo "Updated {$stmt->affected_rows} rows";

$stmt->close();

php mysql bind-param, how to prepare statement for update query