note 65696 added to function.mysqli-prepare
| From: | codeFiend | Date: | Fri, 05 May 2006 21:47:04 +0000 |
| Subject: | note 65696 added to function.mysqli-prepare | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-110665@lists.php.net to get a copy of this message | ||
Note that single-quotes around the parameter markers _will_ prevent your statement from being
prepared correctly.
Ex:
<?php
$stmt = $mysqli->prepare("INSERT INTO City (District) VALUES ('?')");
echo $stmt->param_count." parameters\n";
?>
will print 0 and fail with "Number of variables doesn't match number of parameters in
prepared statement" warning when you try to bind the variables to it.
But
<?php
$stmt = $mysqli->prepare("INSERT INTO City (District) VALUES (?)");
echo $stmt->param_count." parameters\n";
?>
will print 1 and function correctly.
Very annoying, took me an hour to figure this out.
----
Server IP: 66.163.161.117
Probable Submitter: 71.140.185.141
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.mysqli-prepare.php
Edit -- http://master.php.net/note/edit/65696
Del: integrated -- http://master.php.net/note/delete/65696/integrated
Del: useless -- http://master.php.net/note/delete/65696/useless
Del: bad code -- http://master.php.net/note/delete/65696/bad+code
Del: spam -- http://master.php.net/note/delete/65696/spam
Del: non-english -- http://master.php.net/note/delete/65696/non-english
Del: in docs -- http://master.php.net/note/delete/65696/in+docs
Del: other reasons-- http://master.php.net/note/delete/65696
Reject -- http://master.php.net/note/reject/65696
Search -- http://master.php.net/manage/user-notes.php