Undefined offset: 0 and Trying to get property of non-object - 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 offset: 0 and Trying to get property of non-object (/showthread.php?tid=63486) |
Undefined offset: 0 and Trying to get property of non-object - ronaldv - 11-05-2015 my page shows 2 php errors (curiously only on OSX and not Windows 10 or Android): A PHP Error was encountered Severity: Notice Message: Undefined offset: 0 Filename: controllers/Dating.php Line Number: 1822 Backtrace: File: /home/xxx/public_html/application/controllers/Dating.php Line: 1822 Function: _error_handler File: /home/xxx/public_html/index.php Line: 292 Function: require_once A PHP Error was encountered Severity: Notice Message: Trying to get property of non-object Filename: controllers/Dating.php Line Number: 1822 Backtrace: File: /home/xxx/public_html/application/controllers/Dating.php Line: 1822 Function: _error_handler File: /home/xxx/public_html/index.php Line: 292 Function: require_once Line 1822 has: Code: $str = "select * from users WHERE id!='".$this->session->userdata('user_id')."' AND country='".$query1[0]->country_name."' AND image_name!='' AND IS_ONLINE!='0' ORDER BY IS_ONLINE DESC LIMIT 0,6 "; and line 1818: Code: $query1=$this->db->query($str1)->result(); RE: Undefined offset: 0 and Trying to get property of non-object - pdthinh - 11-05-2015 (11-05-2015, 03:03 PM)ronaldv Wrote: my page shows 2 php errors (curiously only on OSX and not Windows 10 or Android): You should use var_dump($query1) after line 1818 to check it has any row return. RE: Undefined offset: 0 and Trying to get property of non-object - ronaldv - 11-06-2015 (11-05-2015, 08:39 PM)pdthinh Wrote: You should use var_dump($query1) after line 1818 to check it has any row return. Do you mean using var_dump() for debugging? I just solved the issue in this way: Code: $result1 = $this->db->query($str1)->result(); RE: Undefined offset: 0 and Trying to get property of non-object - pdthinh - 11-06-2015 Quote:Do you mean using var_dump() for debugging?Yes, I mean that because the errors show that $query1 doesn't have any row returned. Sorry for the confusion. |