php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42113 Problem with placeholders and escaped quotes in string constants
Submitted: 2007-07-26 16:03 UTC Modified: 2007-07-28 09:16 UTC
From: dominique dot archambault at gmail dot com Assigned:
Status: Closed Package: PDO related
PHP Version: 5.2.3 OS: Debian lenny
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dominique dot archambault at gmail dot com
New email:
PHP Version: OS:

 

 [2007-07-26 16:03 UTC] dominique dot archambault at gmail dot com
Description:
------------
Using PHP 5.2.3 and MySQL 5.0.38.

If there are placeholders in string constants of an SQL query, and there are also escaped quotes in a string constant (either the same string constant, or a different one), the following error is triggered:

Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: no parameters were bound in <FILE> on line <LINE>


Reproduce code:
---------------
// WORKS
$stmt = $pdo->prepare("SELECT * FROM `test` WHERE `test`.`text` = \"Hello world's! 2007-01-01 00:00:00\"");
if ($stmt->execute()) {
   print "PASSED!\n";
} else {
   // should not enter this
   print "FAILED!\n";
   var_dump($stmt->errorInfo());
}

// DOES NOT WORK
$stmt = $pdo->prepare("SELECT * FROM `test` WHERE `test`.`text` = 'Hello world\'s! 2007-01-01 00:00:00'");
// the following execute() call will generate the error
if ($stmt->execute()) {
   print "PASSED!\n";
} else {
   // will always enter this
   print "FAILED!\n";
   var_dump($stmt->errorInfo()); // will contain: array(1) { [0]=> string(5) "HY093" }
}


Expected result:
----------------
PASSED!
PASSED!


Actual result:
--------------
PASSED!

Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: no parameters were bound in <FILE> on line <LINE>
FAILED!
array(1) {
  [0]=>
  string(5) "HY093"
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-27 18:42 UTC] dominique dot archambault at gmail dot com
The CVS snapshot (5.2.4) worked and my test case ran flawlessly! It would seem the bug was addressed and corrected.

Only have to wait for the official release of 5.2.4 :) Thank you very much!
 [2007-07-28 09:16 UTC] johannes@php.net
Then it's closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 21:01:36 2024 UTC