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

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

Dharman
  • 30,962
  • 25
  • 85
  • 135
user3522738
  • 81
  • 1
  • 6

1 Answers1

-1

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

}
Dharman
  • 30,962
  • 25
  • 85
  • 135
Gaurav Jain
  • 444
  • 3
  • 13