PDO version problem Invalid parameter number: no parameters were bound
- 2020-05-27 04:30:52
Today in dealing with bug found it very strange questions, some one will quote: when perform certain operations Invalid parameter number: no parameters were bound, but the problem in local or test machine to test all have no, guess whether and version, and then the next google, found http: / / forum typecho. org/topic php? The second floor of the article, id=1501, says that the problem is a version of bug, which appears in pdo below php 5.2.9. Therefore, I asked another machine (5.2.6) in the team to do the test. As expected, the problem was reproduced. When tested on his server on 5.2.17, the problem did not appear.
During debugging, it was found that the following business reported the above error when such operation occurred:
Use PDO to insert a piece of data into the table nw_log (table field 1 some columns uid and so on, and content field), where the content of content field is < a href='http://a.xxx/?tid=1' > test < /a > , and the contents of the table fields are called PDO- before being stored > The quote method does escape. The error was reported on php 5.2.6, but it was normal on 5.2.17.
When I just changed the content to http:// a.xxx /? When tid=1, the performance on the 5.2.6 machine and 5.2.17 machine was normal, so the content format was debugged again as < a href="http://a.xxx/?tid=1" > test < /a > , then 5.2.6 and 5.2.17 are all normal, which seems to be caused by single quotation marks.