title: Error : get property of non-object
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/254291/call-to-a-member-function-on-a-non-object">Call to a member function on a non-object</a>  </p>
  </blockquote>
  
  
  
  <p>I receive this error : Trying to get property of non-object [from Model]
  When i try to retrieve id from database by inputting a string which in this case is 'something'</p>
  
  <p>This is my Model</p>
  
  <pre><code>   function getRoleId($role_name='')
           {
  
              $conditions = array('role_name'=&gt; $role_name);
              $this-&gt;db-&gt;where($conditions);
              $this-&gt;db-&gt;select('id');
              $query = $this-&gt;db-&gt;get('roles');       
              $row   = $query-&gt;row();
              return $row-&gt;id;
           }
  </code></pre>
  
  <p>Controller ($radioRole here is = something) but when it reaches the model it becomes something else.</p>
  
  <pre><code>$radioRole  = 'something';
  $insertData['role_id']            = $this-&gt;user_model-&gt;getRoleId($radioRole);
  </code></pre>
  
  <p>UPDATE </p>
  
  <pre><code>print_r($radioRole);
  $insertData['role_id']            = $this-&gt;user_model-&gt;getRoleId($radioRole);
  </code></pre>
  
  <p>Shows $radioRole which is in this case 'something'</p>
  
  <p>but when it reaches user_model and when i do a print_r it shows something else, 'buyer' , it doesnt even show the print_r done on controller. Feels like its being over written :O but i got no idea :O</p>
  
  <p>print_r($query)</p>
  
  <pre><code>  CI_DB_mysql_result Object ( [conn_id] =&gt; Resource id #37 [result_id] =&gt; Resource id #64 [result_array] =&gt; Array ( ) [result_object] =&gt; Array ( ) [current_row] =&gt; 0 [num_rows] =&gt; 0 [row_data] =&gt; )
  </code></pre>