sql update 查询未执行但未返回错误 [英] sql update query didn't execute but return no errror

查看:59
本文介绍了sql update 查询未执行但未返回错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$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();
}

卡了半个小时还是没查出什么问题.我没有返回错误.我的表看起来像这样 http://i.imgur.com/snwloav.png

stuck for half an hour and still couldn't find out what's wrong. I has return no error. My table look like this http://i.imgur.com/snwloav.png

推荐答案

你可以使用它从 php 更新 mysql

you can use this for updation in mysql from php

if(isset($_POST['submit'])){
    try{
        $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();
  }

}

这篇关于sql update 查询未执行但未返回错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆