I’m confused: I’m getting this error for an invalid number of parameters but I think the number is correct. There must be something I’m missing and I need your help figuring out what.
This is the array I want to INSERT … ON DUPLICATE KEY UPDATE:
$payable_data = array(
'projectID' => $_POST['projectID'],
'date' => $project_data['duedate'],
'vendorID' => $project_data['vendorID'],
'totaltopay'=> ($project_data['subprice'] * $project_data['units']),
'currency' => $project_data['currency'],
'paid' => '0'
);
Six items total. Then I build the UPDATE part of the query:
$update = "";
foreach($payable_data as $payable_key => $payable_value) {
$update .= " ".$payable_key." = ?,";
$update_values[] = $payable_value;
}
$update = substr($update, 0, -1);
Here’s my query (I use a function to create the ? placeholders):
$payableQuery = $db->prepare("INSERT INTO ".PAYABLES." (".implode(',', array_keys($payable_data)).") VALUES (".$options->placeholders($payable_data).") ON DUPLICATE KEY UPDATE".$update."");
And here I execute the query:
$payableQuery->execute($update_values);
Here’s a screenshot of the error:

It’s relatively easy to count the number of parameters – six. What is wrong then?