Hey There,
So i keep on getting a “Paramiter not Defined error” in PDO. All ready have ran the query in PMA so i know that works. Anyways i know that one of the variables is not getting set. I have tested both the post array to see if they are not being sent, but i have confirmed that they are being sent. Then i tested the $values array to see if they are being defined, and they are. So i am at a loss. The exact SQL error is SQLSTATE[HY093] : Invalid parameter number: parameter was not defined.
And here’s the code.
$query = "UPDATE animals SET
colour = :colour,
breed = :breed,
born = :birthdate,
died = :died,
dam = :dam,
sire = :sire,
idtag = :idtag
WHERE animalidid=:animalid";
$values = array (
'colour' => $colour,
'breed' => $breed,
'born' => $born,
'died' => $died,
'dam' => $dam,
'sire' => $sire,
'idtag' => $idtag,
'animalid' => $id
);
try {
$update = $pdo->prepare($query);
$update->execute($values);
$title .= "Record updated succesfully";
$output .= "You have sucessfully updated the record";
} catch (PDOException $e) {
$title .= "Mysql/Pdo error!";
$output .= "we are sorry but there was an error in the script. Here are the details that you can copy & paste to email to us details:: <strong>{$e->getMessage}</strong>";
}
Thanks for the help!