Undefined Index - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Undefined Index (/showthread.php?tid=63963) |
Undefined Index - mpar612 - 12-28-2015 Hi Everyone, I am new to Codeigniter and am working on my first project and am getting an Undefined Index error and am not sure why. I have been modeling my code after the News example on the Codeigniter website. My code is posted below, but it seems that the following line in my controller is not passing the $id to the query in the model, because anytime I try to reference the output of this query (e.g. $data['title'] = $data['family']['familyName']) I get: Quote:Message: Undefined index: familyName. PHP Code: $data['family'] = $this->heart_model->get_families($id); My model is: PHP Code: <?php My Controller is: PHP Code: <?php I appreciate any help. Also, any advice on how I can troubleshoot these types of problems on my own would be appreciated. Thanks! RE: Undefined Index - dhinakar - 12-28-2015 reasons, 1.model not return value for particular index 2.table not contain that index 3.or any spelling errors are occur on script RE: Undefined Index - pdthinh - 12-28-2015 (12-28-2015, 08:24 PM)mpar612 Wrote: Hi Everyone, The result_array() method will return an numeric index array that each element is a record in database. In case you want to get a specific row you should use row_array() instead. For example: PHP Code: public function get_families($id = FALSE) However, I recommend you seperating get_all_families with get_family_by_id for simplicity. PHP Code: public function get_family_by_id($id) RE: Undefined Index - mpar612 - 12-29-2015 pdthinh - worked perfectly. Thank you so much! RE: Undefined Index - pdthinh - 12-29-2015 (12-29-2015, 06:06 PM)mpar612 Wrote: pdthinh - worked perfectly. Thank you so much! You're welcome. |