|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34414 PDO_MYSQL: parameter in INSERT gives syntax error
Submitted: 2005-09-07 22:37 UTC Modified: 2005-09-08 10:31 UTC
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: Roland dot Bouman at interaccess dot nl Assigned:
Status: Not a bug Package: PDO related
PHP Version: 5.1.0RC1 OS: Win XP Professional SP2
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.
Block user comment
Status: Assign to:
Bug Type:
From: Roland dot Bouman at interaccess dot nl
New email:
PHP Version: OS:


 [2005-09-07 22:37 UTC] Roland dot Bouman at interaccess dot nl
A PDO_MYSQL prepared INSERT statement fails to execute. The driver specific error message reports the value of the variable bound to the parameter as an unknown column. 

The error message suggests that the actual statement sent to mysql contains a syntax error because of some flaw in the way the parameter value is put into the sql statement

No such behaviour is observed in a prepared SELECT statement. An equivalent INSERT statement with the quoted parametervalues hardcoded into the insert does execute as expected.

Reproduce code:
$pdo = new PDO('mysql:host','usr','pwd');
$pdo->query('use test');
$pdo->exec('create table tmp(
    id int auto_increment primary key
,   flag enum(\'TRUE\',\'FALSE\')
,   name varchar(10))');
$ins = $pdo->prepare('insert into  test.tmp(
,   name) values (
,   :name)');
$flag = 'TRUE';
$name = 'some name';
print_r($ins->errorInfo()); --generate output

Expected result:
Array ( [0] => ) 


Array ( [0] => 00000 ) 

indicating successfull execution of the statement at the MySQL server.

Actual result:
Array ( [0] => 42S22 [1] => 1054 [2] => Unknown column 'TRUE' in 'field list' ) 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-07 22:40 UTC] Roland dot Bouman at interaccess dot nl
Sorry, the last line of my reproduce code should read:

print_r($ins->errorInfo()); //generate output


print_r($ins->errorInfo()); --generate output
 [2005-09-07 23:44 UTC]
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

 [2005-09-08 10:31 UTC] Roland dot Bouman at interaccess dot nl
sniper, I don't want to bother you with duplicates, so sorry for the inconvenience. 
However, I can't seem to find the bug report you are referring to. (I searched all PDO-related bug reports). Could you give me a pointer?

BTW, I posted 5.1.0RC1 as the version, but I did use the (then) latest snapshot: php5.1-win32-200509071830
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 00:01:33 2024 UTC