|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 18:00:01 2025 UTC |
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"\')'