array index problem - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: array index problem (/showthread.php?tid=14081) |
array index problem - El Forum - 12-17-2008 [eluser]satterle[/eluser] This is driving me crazy. I keep getting a message: "undefined index: on_id". I have no idea what's causing the problem. Any help greatly appreciated. Code: function _get_last_sibling($o_id, $on_pid) array index problem - El Forum - 12-22-2008 [eluser]Henry Weismann[/eluser] Wow that is wierd! Try commenting out: $on_id = $row['on_id']; Do you still get the error. Try $this->db->select('on_id as test'); Then $on_id = $row['test']; print 'on_id : '.$on_id; // print to verify array index problem - El Forum - 12-22-2008 [eluser]JoostV[/eluser] Sounds like your query is not returning results. Check with Code: echo 'numrows = ' . $query->num_rows(); To prevent errors from popping up, check if any rows were returned before processing. Code: // Query database for last sibling Also, if you wish to retrieve just one record, you might want to try adjust your SQL so that you can limit the result using $this->db->limit(1) for a more efficient query. array index problem - El Forum - 01-18-2009 [eluser]d_anank[/eluser] check this: Code: $this->db->select('on_id'); |