#37646 [Com]: Query fails when it contains special characters, something wrong with odbc, pdo
ID: 37646
Comment by: tadiyya at sapplica dot com
Reported By: dipeshkhakhkhar at gmail dot com
Status: No Feedback
Bug Type: PDO related
Operating System: Windows XP
PHP Version: 5CVS-2006-05-31 (snap)
Assigned To: wez
New Comment:
Hi,
I faced the same problem. But i resolved as per my observation that is
not but with PDO. Before inserting or selecting values, you need set
character set for the my sql. I run 'set names utf8' query before
working with special characters. Its working fine.
This might help you.
Cheers,
Adiyya
Previous Comments:
------------------------------------------------------------------------
[2006-12-13 01:00:00] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
[2006-12-05 18:06:12] iliaa@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.2-win32-latest.zip
------------------------------------------------------------------------
[2006-05-31 02:41:26] dipeshkhakhkhar at gmail dot com
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 this bug report at http://bugs.php.net/?id=37646&edit=1
Thread (4 messages)