|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-12-24 10:43 UTC] lapo at lapo dot it
[2011-04-08 21:04 UTC] jani@php.net
-Summary: PDO Some error messages are uninformative
+Summary: Some error messages are uninformative
-Package: Feature/Change Request
+Package: PDO related
[2021-08-27 12:59 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 05:00:02 2025 UTC |
Description: ------------ The error message is given below. PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in xxx.php It would be - extremely - helpful if the error message contained a list of the matched tokens or some information on where the token substitution failed. Reproduce code: --------------- $query = "SELECT * FROM example_table et WHERE start_date BETWEEN ':sStartDate' AND ':sEndDate' AND user_id = :iId" <snip prepare statement> $sStatement->bindParam(':iId', $iUserId, PDO::PARAM_INT); $sStatement->bindParam(':sStartDate', $sStartDate, PDO::PARAM_STR); $sStatement->bindParam(':sEndDate', $sEndDate, PDO::PARAM_STR); $sStatement->execute(); The error PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in xxx.php Expected result: ---------------- Expect to see either no error because it worked or a message such as PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in xxx.php. Cannot find token :sStartDate Actual result: -------------- PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in xxx.php