note 76864 added to function.ocibindbyname
| From: | javier_8 at NOSPAM dot hotmail dot com | Date: | Thu, 02 Aug 2007 21:25:51 +0000 |
| Subject: | note 76864 added to function.ocibindbyname | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-129135@lists.php.net to get a copy of this message | ||
Probably a common error using oci_bind_by_name:
<?php
for ($i=0; $i <= 20; $i++)
{
$ParamName = ':FIELD'.$i;
$Value = $_POST['FIELD'.$i];
oci_bind_by_name($stmt, $ParamName, $Value);
}
?>
This is wrong and you'll get the error:
ORA-01461: can bind a LONG value only for insert into a LONG column
It's because oci_bind_by_name apparently works with placeholders, if you assign all the binds
to the address of "$value", then all of the values will be the same.
You must do this instead:
<?php
for ($i=0; $i <= 20; $i++)
{
$ParamName = ':FIELD'.$i;
oci_bind_by_name($stmt, $ParamName, $_POST['FIELD'.$i]);
}
?>
So oci_bind_by_name links the parameter with the memory space of POST['FIELD1'],
POST['FIELD2'], POST['FIELD3']...
Hope it helps (It took some time to figure this out, and I found no help on the net for this issue).
----
Server IP: 200.59.45.3
Probable Submitter: 200.55.39.210
----
Manual Page -- http://www.php.net/manual/en/function.ocibindbyname.php
Edit -- https://master.php.net/note/edit/76864
Del: integrated -- https://master.php.net/note/delete/76864/integrated
Del: useless -- https://master.php.net/note/delete/76864/useless
Del: bad code -- https://master.php.net/note/delete/76864/bad+code
Del: spam -- https://master.php.net/note/delete/76864/spam
Del: non-english -- https://master.php.net/note/delete/76864/non-english
Del: in docs -- https://master.php.net/note/delete/76864/in+docs
Del: other reasons-- https://master.php.net/note/delete/76864
Reject -- https://master.php.net/note/reject/76864
Search -- https://master.php.net/manage/user-notes.php