php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38178 Problem with parameter detection in queries (HY093)
Submitted: 2006-07-21 16:08 UTC Modified: 2006-12-04 00:46 UTC
Votes:5
Avg. Score:5.0 ± 0.0
Reproduced:4 of 4 (100.0%)
Same Version:4 (100.0%)
Same OS:2 (50.0%)
From: gerald at copix dot org Assigned:
Status: Closed Package: PDO related
PHP Version: 5.1.4 OS: Windows
Private report: No CVE-ID: None
 [2006-07-21 16:08 UTC] gerald at copix dot org
Description:
------------
Using PDO, a simple insert query does not work with "prepare / execute" but works fine using "exec"

This exact query does work correctly if I remove the text '\r\n' at its end.

The query is : 
'INSERT INTO myTable VALUES (\'xml:lang="fr" lang="fr">\r\n\')'

It may be related to the following bugs :
#36923 & #37646

Reproduce code:
---------------
//FOLLOWING DOES NOT WORK
$stmt = $pdo->prepare ('INSERT INTO myTable VALUES (\'xml:lang="fr" lang="fr">\r\n\')');
if (! $stmt->execute ()){
print_r ($stmt->errorInfo ());//contains Array ( [0] => HY093 )
}

//FOLLOWING CODE IS OK (using exec)
if (! $pdo->exec ('INSERT INTO myTable VALUES (\'xml:lang="fr" lang="fr">\r\n\')')){
	print_r ($pdo->errorInfo ());
}

//FOLLOWING CODE IS OK (removed \r\n at the end of the query)
$stmt = $pdo->prepare ('INSERT INTO myTable VALUES (\'xml:lang="fr" lang="fr">\')');
$stmt->execute ();//OK

Expected result:
----------------
PDO should insert the value 'xml:lang="fr" lang="fr">\r\n' in the myTable table, wish is 

CREATE TABLE `myTable` (
`test` VARCHAR( 255 ) NOT NULL
)

Actual result:
--------------
Warning: PDOStatement::execute() [function.PDOStatement-execute]: SQLSTATE[HY093]: Invalid parameter number: no parameters were bound in C:\Program Files\wamp\www\test_3\www\index.php on line 40

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-01 14:07 UTC] iliaa@php.net
What database driver are you using?
 [2006-08-09 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".
 [2006-08-10 19:59 UTC] bugs at mytrashmail dot com
Problem verified on SunOS 5.8 using PHP 5.1.2 und MySQL 4.1.5-gamma for prepared select queries to be executed. Used Driver: MySQL for PDO in the original version for PHP 5.1.2.

Workaround: Last char in query must be semicolon.

Greetings.
 [2006-08-21 08:01 UTC] gerald at copix dot org
@ iliaa > I'm using MySQL driver.
 [2006-09-21 14:25 UTC] gerald at copix dot org
Additionnal queries that do not work and raise the same error : 

'insert into simpletestmain (`string_test`) VALUES ("test:backslash\\")'

And 

'insert into simpletestmain (`string_test`) VALUES (\'test:doublequote"\')'
 [2006-12-04 00:46 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Nov 28 12:03:13 2021 UTC