-1

Here's the code:

$sql1 = "UPDATE muted_alerts SET `customer_id`=':customer_id', `sms_time` = '$fdate', `phone`=':phone'";

$stmt = $dbh->prepare($sql1, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY) );
$stmt->execute(array(':phone' => $phone,':customer_id'=>$customer_id));
$result1 = $stmt->fetchAll(PDO::FETCH_ASSOC);

This throws no errors. I've used var_dump to see if $phone, $fdate and $customer_id are valid and they are.

I'm guessing there's a problem in my statement somehow. I excluded all the $dbh lines for simplicity, but I have tested and know these are correct also.

jonmrich
  • 4,233
  • 5
  • 42
  • 94

1 Answers1

1

Remove the quotes from the fields and the colon in the keys of the array inside of the execute method. You dont need it.See below:

$sql1 = "UPDATE muted_alerts SET customer_id=:customer_id, sms_time = :f_date, phone=:phone";

$stmt = $dbh->prepare($sql1, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY) );
$stmt->execute(array('phone' => $phone,'f_date' => '$fdate','customer_id'=>$customer_id));
$result1 = $stmt->fetchAll(PDO::FETCH_ASSOC);
msantos
  • 691
  • 5
  • 6