[eluser]gigas10[/eluser]
Hey everyone, I'm confused on where to post now, so hopefully I can post this here, I'm also using 1.7.2 still.
Anyway, I'm trying to loop through a post array and input the data into a table, simple enough.
However, I'm getting an Array to string conversion error even though the data submits into the table as it should. I am confused.
Code for the form
Code:
<strong>Work Order Number(s): </strong>
<br />
<?=form_hidden('id', '1');?>
<?=form_input("work_order[]");?>
<br /><br />
<div id="here"></div>
<br />
<a href="#">(+add another work order number)</a>
Here is the code to loop through the input array and submit the data to the table.
Code:
foreach($this->input->post('work_order') AS $value){
$w_input = array();
$w_input['record_id'] = $id;
$w_input['work_order'] = $value;
$this->db->insert('smf_work_order_numbers', $w_input);
}
And here is the exact error.
Code:
A PHP Error was encountered
Severity: Notice
Message: Array to string conversion
Filename: mssql/mssql_driver.php
Line Number: 496
A Database Error Occurred
Error Number:
INSERT INTO smf_work_order_numbers (record_id, work_order) VALUES ('32', Array)
Keep in mind, the code works and the data is submitted to the table successfully. I don't understand why I get this error, because the $value is not an array.