PHP Codeigniter error: call to undefined method ci_db_mysql_driver::result()-Collection of common programming errors

I was trying to create an xml response using codeigniter. The following error gets thrown when i run the code.

This page contains the following errors:

 0)
            {
                foreach ($query->result() as $row){
                    echo ''.$row->title.'';
                }
            }
        }
        echo '';
    }
}
?>
  1. Your code here is wrong:

      $this->db->where('email_id', $email);
                $this->db->limit(1);
                $query = $this->db->from('lp_user_master');
                $this->get();
    

    Should be, instead:

      $this->db->where('email_id', $email);
      $this->db->from('lp_user_master'); 
      $this->db->limit(1);
      $query = $this->db->get();
    

    Now you can call $query->result(), because the result resource is there after you actually get the table results

Originally posted 2013-11-09 22:47:14.