Change $stmt->execute(array($userarray));
to $stmt->execute($userarray);
. Since $userarray
is already an array, you don't need to wrap it in a new array. By wrapping it in a new array like your code was, PDO gets sent 1 parameter when it expected all 6. This is why the error generated said "number of bound variables does not match number of tokens".
PDO PHP Error , Now sure how to fix it?
Frage
I am getting the following errors:
Notice: Array to string conversion in line 371
Warning: PDOStatement::execute() [pdostatement.execute]: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens on line 371
The code which generate this error is below :
// update member file report...
$sql = 'UPDATE memberFileReports SET membersAdded =?, membersCanceled=?, errors=?, dateProcessed=?, totalProcessed=? WHERE id = ?';
$totalToProcess = $membersAdded + $membersCanceled + $totalErrorCount;
$userarray = array($membersAdded,$membersCanceled,$totalErrorCount,date("Y-m-d H:i:s"),$totalToProcess,$fileDataReportId);
$stmt = $this->db->prepare($sql);
$stmt->execute(array($userarray));
Please help ??
Lösung
Andere Tipps
User array variable is set as an array on creation. And on executed os added to other array.
Remove the duplicated array declaration or the execute function thinks theres only one parameter.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow