class CI_DB_mysqli_result could not be converted to string - 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: class CI_DB_mysqli_result could not be converted to string (/showthread.php?tid=65774) |
class CI_DB_mysqli_result could not be converted to string - davy_yg - 07-22-2016 Hello, I am trying to fix this error message but could not find a way out yet. Can anyone help me out? Thanks in advance. A PHP Error was encountered Severity: 4096 Message: Object of class CI_DB_mysqli_result could not be converted to string Filename: views/pcategories.php Line Number: 53 Backtrace: File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\EcommerceGiondaCI\application\views\pcategories.php Line: 53 Function: _error_handler File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\EcommerceGiondaCI\application\controllers\Cpages.php Line: 215 Function: view File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\EcommerceGiondaCI\index.php Line: 315 Function: require_once models/Pages_model.php PHP Code: public function call_menu() controllers/cpages.php PHP Code: public function pcategories() { views/pcategories.php PHP Code: <div class="row-fluid"> Line 53: <td><?php echo $menu; ?></td> RE: class CI_DB_mysqli_result could not be converted to string - InsiteFX - 07-22-2016 Do you know the difference between a result() object and a result_array() array? RE: class CI_DB_mysqli_result could not be converted to string - meow - 07-22-2016 Its all explained in the ci docs here Generating Query Results http://www.codeigniter.com/user_guide/database/results.html In PHP Code: public function call_menu() change Code: return $query->result(); Code: return $query->result_array(); This will give you an array to work with as follows from the controller PHP Code: public function pcategories() And in your view you can show the results as follows PHP Code: foreach ($menu as $array => $row) RE: class CI_DB_mysqli_result could not be converted to string - InsiteFX - 07-22-2016 He never learns anything he just keeps asking the same error questions over and over. Sit down and take the time to try and learn what your trying to do. Google search is your friend. |