CodeIgniter Forums
Problem creating a helper (Error undefined offset) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Problem creating a helper (Error undefined offset) (/showthread.php?tid=58563)



Problem creating a helper (Error undefined offset) - El Forum - 06-24-2013

[eluser]yoelrodguez[/eluser]
Hi I had problems with this helper that I created in codeigniter me this error is generated (Message: Undefined offset: 2) in the line:
($ iten == $ array [$ v])? $ found = true $ found ='';
happened also the code of the function:
$v = 0;
foreach($array as $key => $value){

$data = array(
$campo2=>$value,
$campo1=>$id
);

$ci->db->where($campo1, $id);
$qi = $ci->db->get($tabla);

foreach($qi->result() as $rows){

$found = false;
$iten = $rows->$campo2;

($iten == $array[$v])? $found = true: $found = '';

if($found == false){
$ci->db->insert($tabla,$data);
}
$v++;
}
}