user2603903
user2603903

Reputation: 1

Code Igniter giving error Fatal error

I following code is giving me error "Fatal error: Call to a member function num_rows() on boolean"

        $query = $this->CI->db->get($this->sess_table_name);
        if ($query->num_rows() == 0)
        {
            $this->sess_destroy();
            return FALSE;
        }

Upvotes: 0

Views: 62

Answers (2)

Mayank Pandeyz
Mayank Pandeyz

Reputation: 26258

Call to a member function num_rows() on boolean means your query:

$this->CI->db->get($this->sess_table_name);

is fails due to some error and it returns FALSE, which is the the return type of select query in case of failure.

So first of all check what $this->sess_table_name contains in it and after that print RAW QUERY by using:

 $this->db->last_query();

and check what is the issue.

Upvotes: 1

Clarence
Clarence

Reputation: 721

You can insert a var_dump before if statement. $query must be false.

Maybe two reasons:

  1. Your database connection is lost.
  2. Or, $this->sess_table_name is not a valid data table name.

Upvotes: 0

Related Questions