Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
After moving my project from my test box (Debian VM on my PC) to a production server (through SQL export/import), this query stopped working, giving the following error:
[0] : ===PDO MESSAGE===
SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
===SQL===========
SELECT ope_doc FROM tblOperazioni WHERE ((ope_data_pagamento >= '2023-01-01')) ORDER BY ope_doc DESC LIMIT 1;
===BACK TRACE====
/web/htdocs/---hidden---/core/nuform.php(509) : eval()'d code - line 8 (nuRunQuery)
/web/htdocs/---hidden---/core/nuform.php - line 509 (eval)
/web/htdocs/---hidden---/core/nuform.php - line 482 (nuOnProcess)
/web/htdocs/---hidden---/core/nuapi.php - line 84 (nuGetFormObject)
The query is on a BE block of a form, and works perfectly on the test box...
This error message typically occurs when the number of parameters (placeholders) in the SQL query does not match the number of values that you are trying to bind to those placeholders.
$query = "SELECT * FROM users WHERE id = ? AND username = ?";
nuRunQuery($query, ['12312']);
In this example, the query has two parameters (:id and :username), but we are only binding a value to one of them (:id). This will result in the "Invalid parameter number" error.
Yes kev1n, that's what I found googling also. But:
1) I don't see such a mistake in my query;
2) the query works perfectly on my Debian VM;
3) the query works perfectly on my provider's phpMyAdmin.
Can be related with the different DB engines (I use MySQL, the provider Percona)?
True, I didn't pay attention. Problems of copy-and-pasting, shame on me.
Now it works on both platforms, I am just eager to understand why this stupid error didn't show up on my box, driving me mad...