#42113 [NEW]: Problem with placeholders and escaped quotes in string constants

From: Date: Thu, 26 Jul 2007 16:03:44 +0000
Subject: #42113 [NEW]: Problem with placeholders and escaped quotes in string constants
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-115474@lists.php.net to get a copy of this message
From: dominique dot archambault at gmail dot com Operating system: Debian lenny PHP version: 5.2.3 PHP Bug Type: PDO related Bug description: Problem with placeholders and escaped quotes in string constants 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 bug report at http://bugs.php.net/?id=42113&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42113&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42113&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42113&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=42113&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=42113&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=42113&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=42113&r=needscript Try newer version: http://bugs.php.net/fix.php?id=42113&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=42113&r=support Expected behavior: http://bugs.php.net/fix.php?id=42113&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=42113&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=42113&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=42113&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42113&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=42113&r=dst IIS Stability: http://bugs.php.net/fix.php?id=42113&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=42113&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=42113&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=42113&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=42113&r=mysqlcfg

« previous php.bugs (#115474) next »