SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match…
- User
SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
- Assistant
This error means that your SQL statement has ? parameters (placeholders for bound variables), but you didn't actually bind that many variables to the statement. For example, if your SQL was: SELECT * FROM users WHERE id = ? AND name = ?
Then you'd need to bind two variables to the statement - likely with a call like: stmt.bind_param('ii', name)
But if you only bound one variable, you'd get this HY093 error since the number of bound variables (1) doesn't match the number of tokens (2) in the SQL. So you just need to ensure you bind the correct number of variables to match the number of placeholders in your SQL statement.
- User
How do determine how many placeholders I have?
- Assistant
The number of placeholders in an SQL statement can be determined by counting the number of ? parameters in it. For example, in my previous example there are two parameters which are ? parameters: "id = ?" and "name = ?". By changing one parameter to a fix value it would have only one placeholder. For example: SELECT * FROM users WHERE id = ? AND name = "John Doe"
As you can see, in this modified SQL statement the "name" parameter was changed to "John Doe" from a placeholder, so now only the "id" parameter is a placeholder.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →