CodeIgniter Forums

Full Version: Call to a member function row() on boolean
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi. I am new to codeigniter and I need help with an existing application I'm working on.  We changed the database that runs in ms sql. We created a beta that runs in the same server as the production. I tested the connection in my local unit, and connection runs no issue. But when I deployed it on Beta, it seems i can't run queries. I would get Fatal error: Call to a member function row() on boolean. I am able to display all tables in my database but can't seem to run a query. This table is existing in the database and has a content as well. Any help is very much appreciated.
Sample code below:
foreach ($tables as $table)
 echo "<br>".$table;

     $query = $this->db->get("tblContents");

     foreach ($query->result() as $row)
      echo "<br/>";
      echo "Name: ".$row->name;
      echo " Path: ".$row->path;

I do not see any calls to db->row() in your code, so I suspect the code you're showing is not the trouble spot. That said, the error message "Call to a member function [some_query_builder_method()] on boolean" is an indication that db->get() or db->get_where() has failed and returned FALSE. If those methods succeed they return a CI_DB_result object.

You can, and probably should, always check that you got something usable before proceeding.

PHP Code:
$query $this->db->get("tblContents");
    foreach ($query->result() as $row)
         echo "<br/>";
         echo "Name: ".$row->name;
         echo " Path: ".$row->path;
   //respond to the failed query, i.e. throw an exception or something