Saturday, 24 August 2013

Invalid parameter number: parameter was not defined

Invalid parameter number: parameter was not defined

Error I'm receiving
Warning: PDOStatement::execute() [pdostatement.execute]: SQLSTATE[HY093]:
Invalid parameter number: parameter was not defined in Trader.class.php on
line 342
Prepare statement
$q = $db->prepare("UPDATE trades SET spentComplete=:spent,
amountComplete=:amount, avgCostComplete=:avg_cost,
dateComplete=:finish_date WHERE orderid =:orderid");
I've tried this two ways and get the same error.
Method 1)
$spent = $tradeInfo["total_spent"];
$amount = $tradeInfo["total_amount"];
$avg_cost = $tradeInfo["avg_cost"];
$finishDate = $tradeInfo["finsh_date"];
$orderid = $tradeInfo["orderid"];
Method 2)
$q->bindParam(':spent', $tradeInfo["total_spent"]);
$q->bindParam(':amount', $tradeInfo["total_amount"]);
$q->bindParam(':avg_cost', $tradeInfo["avg_cost"]);
$q->bindParam(':finsh_date', $tradeInfo["finsh_date"]);
$q->bindParam(':orderid', $tradeInfo["orderid"]);
Here's a var_dump of $tradeInfo
array(6) { ["price"]=> string(8) "11979994" ["total_spent"]=> string(6)
"236572" ["total_amount"]=> string(7) "1974725" ["avg_cost"]=> string(8)
"11979997" ["finsh_date"]=> int(1376981844) ["orderid"]=> string(36)
"7d60a914-0b3c-45dc-9c36-9ed74d03ba69" }
I've double, triple, and quadruple checked my work I can't find the error.

No comments:

Post a Comment