Reputation: 6265
EDIT: It turns out that I've been barking up the wrong tree so to speak. I've edited the question to make it at least useful for others who get the error.
For all those who get the following error when trying to execute a prepared PDO query:
Warning: PDOStatement::execute() [pdostatement.execute]: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined on line 26
See my answer below.
Upvotes: 3
Views: 139
Reputation: 6265
That means you are passing more array values in $query->execture($array)
than you have :values
in the query. If you are getting a similar but differently worded error, it mean you have more :values
in the query than you have in the array. For example:
$array = array(
'username' => 'Bob',
'id' => 42,
);
//...
$query = "SELECT * FROM `users` WHERE `id`=:id";
//...
$data->execute($array);
This would give an error because, although you are passing "username", it is never used in the query. Hope this helps someone!
Upvotes: 1