PDO multiple queries in php /sql -
i have following code. grabbing values form, , using values try update "customers" , "workorder". "name" value duplicate across customers , workorder table. keep on getting error "number of bound variables not match number of tokens". totally new using pdo, , unsure on how proceed. ideas?
$pdo = database::connect(); $pdo->setattribute(pdo::attr_errmode, pdo::errmode_exception); $sql = "update customers set name = ?, email = ?, mobile =? id = ?; update workorder set name = ?;"; $q = $pdo->prepare($sql); $q->execute(array($name,$email,$mobile,$id)); database::disconnect(); header("location: index.php");
you have 4 variables here:
$q->execute(array($name,$email,$mobile,$id));
should 5:
$q->execute(array($name,$email,$mobile,$id, $name));
Comments
Post a Comment