|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-05-26 15:18 UTC] johannes@php.net
[2011-06-05 00:54 UTC] felipe@php.net
-Summary: Parse error with single quote in sql comment
(pdo-mysql)
+Summary: Parse error with single quote in sql comment
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: felipe
[2011-06-05 00:54 UTC] felipe@php.net
[2011-06-05 00:54 UTC] felipe@php.net
[2012-04-18 09:50 UTC] laruence@php.net
[2012-07-24 23:41 UTC] rasmus@php.net
[2013-11-17 09:37 UTC] laruence@php.net
[2024-05-31 06:13 UTC] geraldine1989jones at outlook dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 03:00:01 2025 UTC |
Description: ------------ Using php 5.2.17 Tested PDO with mysql, haven't tried other drivers. Configure Command => './configure' '--disable-cgi' '--with-mysql' '--enable-pdo' '--with-pdo-mysql' '--with-libdir=lib64' There is a PDO parsing error when a single quote is inside a block comment. This seems to only occur when there is an input parameter between a commented single quote and any other single quote, either as part of the query or in another comment. It looks like the single quotes aren't getting ignored in the comment, and cause parameters to not be replaced with their values. Example SQL that causes a parse error: /* ' */ select ? as f1, 'foo' as f2 This also causes errors: /* ' */ select ? as f1 /* ' */ Test script: --------------- <? //This query breaks: $query = "/* ' */ select ? as f1, 'bar' as f2"; //This query also breaks: //$query = "/* ' */ select ? as f1 /* ' */"; $pdodb = new PDO("mysql:dbname=test;host=127.0.0.1", "testuser", "testuser"); $stmt = $pdodb->prepare($query); if (!$stmt->execute(array("foo"))) { $errInfo = $stmt->errorInfo(); print_r($errInfo); } ?> Expected result: ---------------- The single quotes should be completely ignored when inside comments, and the ? should be replaced with the input parameter value "'foo'". Actual result: -------------- The query doesn't execute successfully, with the following PDO error info: [0] => 42000 [1] => 1064 [2] => You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? as f1, 'bar' as f2' at line 1