#42113 [Opn->Fbk]: Problem with placeholders and escaped quotes in string constants
| From: | iliaa@php.net | Date: | Fri, 27 Jul 2007 00:04:36 +0000 |
| Subject: | #42113 [Opn->Fbk]: Problem with placeholders and escaped quotes in string constants | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-115485@lists.php.net to get a copy of this message | ||
ID: 42113
Updated by: iliaa@php.net
Reported By: dominique dot archambault at gmail dot com
-Status: Open
+Status: Feedback
Bug Type: PDO related
Operating System: Debian lenny
PHP Version: 5.2.3
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows (zip):
http://snaps.php.net/win32/php5.2-win32-latest.zip
For Windows (installer):
http://snaps.php.net/win32/php5.2-win32-installer-latest.msi
Previous Comments:
------------------------------------------------------------------------
[2007-07-26 16:03:44] 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"
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42113&edit=1