Parmater Not defied

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);
			$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 &amp; paste to email to us details:: <strong>{$e->getMessage}</strong>";		

Thanks for the help!

You used born instead of birthdate in your $values array

Wow it’s early in the morning. Thanks!

Hey there,

So now the script when run is not updating the details in the database. Any ideas why? I am defing $pdo in a config file and including that file in the page.

Yep, take a look at your query, the WHERE clause. If it doesn’t jump out at you, take a real close look at your animalidid :wink:

The animal did a job on me! You guys must think i am drunk all the time.

<On a side not i must be to use UPS as a shipping company to get things from the us to Canada. Just paid 1/3 the value of the item in brokerage fees!>

Nah, we all have those days, which is why paired programming was invented :slight_smile: So the person next to you stops you from making such mistakes (or are there to remind you have all of those mistakes you made) :wink:


Glad it’s not just me!

I ordered a microscope and slides. All to gather it would be about 180-190 usd range. I paid 69 almost 70 in brokerage fees!

I changed that Id name in the database layout so i can easily remeber it. Now it is simpley Aid. (updating all scripts to new format now)