Note that there are some explanatory texts on larger screens.

plurals
  1. POCodeigniter array to string conversion error
    primarykey
    data
    text
    <p>I am receiving this error when posting with update_batch. I have seen other posts on this but my line reference is to the DB_active_rec.php file and others were seeing it in their MC. The error doesn't stop the update_batch from posting and it returns the error for each $rb_items. <img src="https://i.stack.imgur.com/crdG1.png" alt="enter image description here"></p> <p>Controller:</p> <pre><code> public function update_rb(){ $rb_items = array(); $rb_id=$this-&gt;input-&gt;post('id', TRUE); $rb_brand=$this-&gt;input-&gt;post('brand', TRUE); $rb_tasted=$this-&gt;input-&gt;post('tasted', TRUE); $rb_rating=$this-&gt;input-&gt;post('rating', TRUE); $rb_comment=$this-&gt;input-&gt;post('comment', TRUE); $i=0; foreach($rb_id as $id){ $rb_items[$i] = array( 'id'=&gt;$id, 'brand'=&gt;$rb_brand[$i], 'rating'=&gt;$rb_rating[$i], 'comment'=&gt;$rb_comment[$i] ); if(empty($rb_tasted)){ $rb_items[$i]['tasted']=0; } else if (in_array($id,$rb_tasted)){ $rb_items[$i]['tasted']=1; } else{ $rb_items[$i]['tasted']=0; } $i++; } $this-&gt;model-&gt;update_rb($rb_items); } </code></pre> <p>Model:</p> <pre><code> public function update_rb($rb_items){ $this-&gt;rb_db-&gt;update_batch('rb_selection',$rb_items,'id'); } </code></pre> <p>View:</p> <pre><code> &lt;tr&gt; &lt;input type="hidden" name="id[]" value="&lt;?php echo $row['id'];?&gt;"&gt; &lt;input type="hidden" name="brand[]" value="&lt;?php echo $row['brand'];?&gt;"&gt; &lt;td&gt;&lt;?php echo "&lt;p&gt;".$row['brand']."&lt;/p&gt;";?&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="checkbox" &lt;?php if($row['tasted'] == 1){echo "checked = checked";}?&gt; name="tasted[]" value="&lt;?php echo $row['id'];?&gt;" id="tasted"/&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="rating[]" &lt;?php echo $row['rating'];?&gt;/&gt;&lt;/td&gt; &lt;td&gt;&lt;textarea name='comment[]' id='comment' cols="350"&gt;&lt;?php echo $row['comment'];?&gt;&lt;/textarea&gt;&lt;/td&gt; &lt;/tr&gt; </code></pre> <p>Has anyone seen this error or know what I am missing in my code? Thanks for the help!</p> <p><code>print_r($rb_items)</code> returns <code>Array ( [0] =&gt; Array ( [rb_id] =&gt; 192 [brand] =&gt; Napa Valley Soda Co [rating] =&gt; r0 [comment] =&gt; c0 [tasted] =&gt; 1 ) [1] =&gt; Array ( [rb_id] =&gt; 193 [brand] =&gt; Natural Brew [rating] =&gt; r1 [comment] =&gt; c1 [tasted] =&gt; 1 ) [2] =&gt; Array ( [rb_id] =&gt; 194 [brand] =&gt; Naturale 90 [rating] =&gt; r2 [comment] =&gt; c2 [tasted] =&gt; 1 ) )</code> for a view with three brands on it. All of this is posting correctly regardless of the error.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload