Welcome Guest, Not a member yet? Register   Sign In
Fatal error: Call to a member function on a non-object
#3

[eluser]FrankieShakes[/eluser]
hellboy,

The error is actually being caused in this line of your view:

Code:
<?php foreach($query->result() as $row): ?>

If you look at the model's "get_last_ten_articles()" method, your return is the actual "result set", so you would either change the view to be:

Code:
<?php foreach($query as $row): ?>

or, rather than returning the result set in the model, you could do:

Code:
function get_last_ten_articles()
    {
        $this->load->database();
        //$query = $this->db->get('articles');
        $query = $this->db->query('SELECT * FROM articles');
        if($query->num_rows() > 0){
            echo $query->num_rows().' Rows';
            return $query;   // return query object, and not result set
        } else {
            echo 'No Rows';
            return array();
        }
    }


Messages In This Thread
Fatal error: Call to a member function on a non-object - by El Forum - 08-12-2007, 05:52 AM
Fatal error: Call to a member function on a non-object - by El Forum - 08-12-2007, 07:03 AM
Fatal error: Call to a member function on a non-object - by El Forum - 08-12-2007, 08:21 AM
Fatal error: Call to a member function on a non-object - by El Forum - 08-12-2007, 03:55 PM
Fatal error: Call to a member function on a non-object - by El Forum - 08-12-2007, 04:48 PM



Theme © iAndrew 2016 - Forum software by © MyBB