#37646 [NEW]: Query fails when it contains special characters, something wrong with odbc, pdo

From: Date: Wed, 31 May 2006 02:41:27 +0000
Subject: #37646 [NEW]: Query fails when it contains special characters, something wrong with odbc, pdo
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-97835@lists.php.net to get a copy of this message
From: dipeshkhakhkhar at gmail dot com Operating system: Windows XP PHP version: 5CVS-2006-05-31 (snap) PHP Bug Type: PDO related Bug description: Query fails when it contains special characters, something wrong with odbc, pdo Description: ------------ Hi, When i tried to execute the following query using PDO execute method, it failed and gave me the following error. I have tried on two different version php 5.1.2 an php 5.2 My query had a strign with the following value. 'AUX:2:2\\?\ACPI#PNP0C0C#2&daba3ff&0#{4afa3d53-74a7-11d0-be5e-00a0c9062857}' Error: HY093 SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters OS: Windows XP Database: db2 Extensions to use pdo from php. extension=php_pdo.dll extension=php_pdo_odbc.dll When i directly insert into my database the same query works fine but from php it gives me the error. If you need more information please informe me. Thanks! Regards, Dipesh Reproduce code: --------------- DB stmt. ------- CREATE SEQUENCE foo_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE CREATE TABLE foo( foo_id BIGINT NOT NULL, foo_value varchar(252)); php statements: -------------- <?php $dbName = ""; // your database name $port = "50000"; $hostName ="127.0.0.1"; $user = '' ; // user name $pass = ''; // password $db = new PDO('odbc:DRIVER={IBM DB2 ODBC DRIVER};hostname='.$hostName.';PORT='.$port.';DATABASE='.$dbName.';PROTOCOL=TCPIP', $user, $pass); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->beginTransaction(); $testsql = "insert into foo (foo_id, foo_value) values ( nextval for foo_seq, 'AUX:2:2\\?\ACPI#PNP0C0C#2&daba3ff&0#{4afa3d53-74a7-11d0-be5e-00a0c9062857}')"; try { $stmt = $db->prepare($testsql); if(!$stmt->execute()){ echo "error in execute statement "; }else echo "Successful execute "; } catch(PDOException $e) { echo "statement failed in execute method ".$testsql."\n "; echo "Error is ".$e->getCode()." " . $e->getMessage() ."\n "; } $db->commit(); ?> Expected result: ---------------- It should run the query and insert the values into the database without throwing any exception. Actual result: -------------- It throws an exception which is as follows: statement failed in execute method insert into foo (foo_id, foo_value) values ( nextval for foo_seq, 'AUX:2:2\?\ACPI#PNP0C0C#2&daba3ff&0#{4afa3d53-74a7-11d0-be5e-00a0c90 62857}') Error is HY093 SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters -- Edit bug report at http://bugs.php.net/?id=37646&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37646&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=37646&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37646&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=37646&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=37646&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=37646&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=37646&r=needscript Try newer version: http://bugs.php.net/fix.php?id=37646&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=37646&r=support Expected behavior: http://bugs.php.net/fix.php?id=37646&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=37646&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=37646&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=37646&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37646&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=37646&r=dst IIS Stability: http://bugs.php.net/fix.php?id=37646&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=37646&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=37646&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=37646&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=37646&r=mysqlcfg

« previous php.bugs (#97835) next »