php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37646 Query fails when it contains special characters, something wrong with odbc, pdo
Submitted: 2006-05-31 02:41 UTC Modified: 2006-12-13 01:00 UTC
Votes:7
Avg. Score:4.1 ± 1.5
Reproduced:6 of 6 (100.0%)
Same Version:2 (33.3%)
Same OS:2 (33.3%)
From: dipeshkhakhkhar at gmail dot com Assigned: wez (profile)
Status: No Feedback Package: PDO related
PHP Version: 5CVS-2006-05-31 (snap) OS: Windows XP
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2006-05-31 02:41 UTC] 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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-05 18:06 UTC] 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-12-13 01:00 UTC] 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".
 [2010-01-02 05:53 UTC] tadiyya at sapplica dot com
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
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 29 19:01:30 2024 UTC