Call to a member function row() on boolean - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Call to a member function row() on boolean (/showthread.php?tid=71889) |
Call to a member function row() on boolean - tenshinadela - 10-05-2018 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: Code: foreach ($tables as $table) RE: Call to a member function row() on boolean - dave friend - 10-05-2018 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"); RE: Call to a member function row() on boolean - gelson - 11-23-2020 @ dave friend seems like your suggestion didn't work... to make it worse echo are not manifesting in the browser for the variable values. anyways this is my issue below An uncaught Exception was encountered Type: Error Message: Call to a member function row() on boolean Filename: /home/tauenjic/code.tauenji.com/install/application/models/Login_model.php and this is my code: <?php class login_model extends CI_Model { function cek_login($where) { $this->db->order_by('user_name', 'DESC'); print_r($this->db->get_where('admin', $where)->row()); $query=$this->db->get_where('admin', $where)->row_array(); $data = array(); if($query !== FALSE && $query->num_rows() > 0){ foreach ($query->result_array() as $row) { $data[] = $row->row_array(); } } return $data; } } anywayz hope someone out there is able to help me solve this issue for real RE: Call to a member function row() on boolean - InsiteFX - 11-23-2020 Did you try using: PHP Code: $this->db->reset_query() Between the two queries? RE: Call to a member function row() on boolean - gelson - 11-23-2020 yes tried that reset_query() between the queries and in every other possible line. but the Uncaught exception error keeps obssessing over the "row_array()" or even "result_array()": An uncaught Exception was encountered Type: Error Message: Call to a member function row_array() on boolean Filename: /home/tauenjic/code.tauenji.com/install/application/models/Login_model.php Line Number: 9 Backtrace: File: /home/tauenjic/code.tauenji.com/install/application/controllers/Login.php Line: 101 Function: cek_login File: /home/tauenjic/code.tauenji.com/install/index.php Line: 326 Function: require_once For some reason its reacting to the row_array() $query=$this->db->get_where('admin', $where)->row_array(); RE: Call to a member function row() on boolean - InsiteFX - 11-24-2020 You already assigned $query an row_array then you are reassigning it with an result_array. Try this and see if it works, not tested. PHP Code: // change this RE: Call to a member function row() on boolean - gelson - 11-24-2020 well, still not fetching anything from the database sir... and the echo prints aren't showing any values $this->db->order_by('user_name', 'DESC'); $query=$this->db->get_where('admin', $where); $data = array(); if($query !== FALSE && $query->num_rows() > 0){ foreach ($query->row_array() as $row) { $data[] = $row; print_r("testing"); print_r($data[num_rows()]); echo ("testing"); $data[] = $row->row_array(); } } return $data; ---------------------------------------------------------------------------------------------- THIS IS A SMALL ALGORITHM TESTING IF THERE IS CONNECTIVITY TO THE DATABASE THUS PROVING THERE IS NO ISSUE WITH DATABASE CONNECTIVITY: //CHECKING DATABASE CONNECTIVITY $servername = "localhost"; $database = "tauenjic_igni811"; $username = "tauenjic_igni811"; $password = "uh.pS509(7"; // Create connection $conn = new mysqli($servername, $username, $password, $database); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } echo "Database has Connected successfully so means connectivity is not the problem"; //CHECKING DATABASE CONNECTIVITY -------------------------------------------------------------------------------------------------------------- RE: Call to a member function row() on boolean - InsiteFX - 11-24-2020 You can use this helper to show a formatted var_dump of the array's It sounds like your not getting the data from the database. PHP Code: <?php Use the helper to check your array's to see if your getting the data. |