mysql error when using named parameters in a query with high ascii
| Bug #36798 | mysql error when using named parameters in a query with high ascii | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2006-03-20 15:50 UTC | Modified: | 2006-12-05 18:06 UTC |
|
||||||||||
| From: | albert at jool dot nl | Assigned: | ||||||||||||
| Status: | Closed | Package: | PDO related | |||||||||||
| PHP Version: | 5.1.2 | OS: | Debian Sarge | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2006-03-20 15:50 UTC] albert at jool dot nl
Description:
------------
Create a PDO_MYSQL connection ($db in the example code). Prepare a query with high ascii values between single quotes (update queries are often affected) and one or more named parameters. Execute the query.
Reproduce code:
---------------
$query = "
SELECT '?' as test
FROM test
WHERE id = :id";
$stm = $db->prepare($query);
$stm->execute(array(":id" => 1));
Expected result:
----------------
No errors, query is correct when executed directly under mysql.
Actual result:
--------------
SQLSTATE[42000]: Syntax error or access violation: 1064 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 ':id' at line 3
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2006-03-20 15:54 UTC] albert at jool dot nl
[2006-03-20 16:52 UTC] albert at jool dot nl
Tried the snapshot, and the problem still exists. Perhaps you aren't seeing the error because you need to explicitly set exception handling: $db = new PDO("mysql:host=$dbHost;dbname=$dbName", $dbUser, $dbPass); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); [.. and then the code ..][2006-03-20 16:53 UTC] albert at jool dot nl
[2006-03-21 15:41 UTC] iliaa@php.net
[2006-03-22 19:53 UTC] albert at jool dot nl
[2006-12-05 18:06 UTC] iliaa@php.net