#34414 [NEW]: PDO_MYSQL: parameter in INSERT gives syntax error

From: Date: Wed, 07 Sep 2005 20:37:31 +0000
Subject: #34414 [NEW]: PDO_MYSQL: parameter in INSERT gives syntax error
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-84648@lists.php.net to get a copy of this message
From: Roland dot Bouman at interaccess dot nl Operating system: Win XP Professional SP2 PHP version: 5.1.0RC1 PHP Bug Type: PDO related Bug description: PDO_MYSQL: parameter in INSERT gives syntax error Description: ------------ 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: --------------- <?php $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( flag , name) values ( :flag , :name)'); $ins->bindParam(':flag',$flag,PDO_PARAM_STR); $ins->bindParam(':name',$name,PDO_PARAM_STR,20); $flag = 'TRUE'; $name = 'some name'; $ins->execute(); print_r($ins->errorInfo()); --generate output ?> Expected result: ---------------- Array ( [0] => ) or 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' ) -- Edit bug report at http://bugs.php.net/?id=34414&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34414&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=34414&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=34414&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=34414&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=34414&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=34414&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=34414&r=needscript Try newer version: http://bugs.php.net/fix.php?id=34414&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=34414&r=support Expected behavior: http://bugs.php.net/fix.php?id=34414&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=34414&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=34414&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=34414&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34414&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=34414&r=dst IIS Stability: http://bugs.php.net/fix.php?id=34414&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=34414&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=34414&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=34414&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=34414&r=mysqlcfg

« previous php.bugs (#84648) next »