insert multiple rows into oracle database.
Posted: Tue Apr 06, 2010 4:28 pm
I need help inserting multiple rows into an Oracle database. I get some errors. I think it is because I need to be using a loop to do the insert but I do not know how. I could also possibly be doing the binding wrong. I start out with a form and then POST to a PHP page and go from there.
Here is the form in short notation
insert.php
Since all of the fields are not null and I have ten rows in the form according to the for loop, I would like to somehow check to see which rows are blank. Meaning that they were not filled out and get rid of them. Otherwise there would be an error on insert becasue the fields are not null.
Here is the form in short notation
Code: Select all
form.php
for($i=0;$i<=10;$i++)
{
<input fname="first[]/>
<input lname="last[]"/>
<input age ="age[]"/>
}insert.php
Code: Select all
$fname = $_POST['first'];
$lname = $_POST['last'];
$age = $_POST['age'];
** NOTE: These are now arrays.
***** I think somewhere here I need to do a loop for the insert
$result = oci_parse($conn, 'INSERT INTO TABLE (first,last,age) VALUES (:first,:last,:age)');
**** I get an error on the binds saying I cannot have an array to string conversion.
oci_bind_by_name($result, ':first',$first);
oci_bind_by_name($result, ':last',$last);
oci_bind_by_name($result, ':age',$age);