note 76864 deleted from function.ocibindbyname by sixd
| From: | sixd@php.net | Date: | Wed, 20 Nov 2013 19:50:23 +0000 |
| Subject: | note 76864 deleted from function.ocibindbyname by sixd | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-197597@lists.php.net to get a copy of this message | ||
Note Submitter: javier_8 at NOSPAM dot hotmail dot com
----
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).