Note that there are some explanatory texts on larger screens.

plurals
  1. POtrying to get property of non-object codeigniter
    text
    copied!<p>I am calling a function twice from two different functions, But for one of the function it says "trying to get property of non-object" first function is </p> <pre><code>$sql=$this-&gt;db-&gt;query("select * from gl_events where entry_id='$entry_id'"); if($sql-&gt;num_rows() &gt; 0) { $row3=$sql-&gt;row(); $event_respond[] = array( 'entry_id'=&gt;$row3-&gt;entry_id, 'event_title'=&gt;$row3-&gt;event_title, 'location'=&gt;$row3-&gt;event_loc_add_ln1, 'location1'=&gt;$row3-&gt;event_loc_add_ln2, 'start'=&gt;$row3-&gt;event_start_date, 'start1'=&gt;$row3-&gt;event_start_time, 'created'=&gt;$row3-&gt;user_id, 'about'=&gt;$row3-&gt;event_descr, 'end'=&gt;$row3-&gt;event_end_time, 'end1' =&gt; $row3-&gt;event_end_time, 'userid'=&gt;$row3-&gt;user_id, //here the function goes to gl_get_att function and //calls gl_getusername function, 'attend'=&gt;$this-&gt;gl_get_att($row3-&gt;entry_id), // here it calls gl_getusername function directly 'username'=&gt;$this-&gt;gl_getusername($row3-&gt;user_id) ); } </code></pre> <p><strong>gl_get_att</strong> definition:</p> <pre><code>public function gl_get_att($entry_id) { $query=$this-&gt;db-&gt;query("select * from gl_event_participants where event_id='$entry_id'"); //echo "select * from gl_event_participants where event_id='$entry_id'"; $row1=$query-&gt;row(); foreach($query-&gt;result() as $row) { $data[]= array( 'user_id'=&gt;$row-&gt;user_id, 'username'=&gt;$this-&gt;gl_getusername($row-&gt;user_id)// here it calls get username function ); } //print_r($data[1]); //print_r($data[0]); return $data; } </code></pre> <p><strong>gl_getusername</strong> definition:</p> <pre><code>public function gl_getusername($user_id) { $query=$this-&gt;db-&gt;query("select user_name from gl_user where user_id = '$user_id'"); $row1=$query-&gt;row(); //print_r($row1-&gt;user_name); return $row1-&gt;user_name; //This is line 396 } </code></pre> <p>Now for gl_get_att its returning the proper values but for the first function where i have called it directly its not working</p> <pre><code>error message: A PHP Error was encountered Severity: Notice Message: Trying to get property of non-object Filename: events/gl_event_model.php Line Number: 396 </code></pre> <p>line 396 is marked above</p> <p>This was working fine on saturday after the weekend its not working !!! strange</p>
 

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