Prals Prals - 1 year ago 181
PHP Question

Call to undefined method CI_DB_mysqli_result::results()

I am very new to CodeIgniter. I am getting below error. Can someone please help me out. I checked various answers on StackOverflow but none helped me.

An uncaught Exception was encountered

Type: Error

Message: Call to undefined method CI_DB_mysqli_result::results()

Filename: /Applications/XAMPP/xamppfiles/htdocs/CodeIgniter/application/controllers/Stud_controller.php

Line Number: 10


File: /Applications/XAMPP/xamppfiles/htdocs/codeigniter/index.php
Line: 315
Function: require_once

Below is the controller code

Class Stud_controller extends CI_Controller{
function __construct(){

public function index(){
$query = $this->db->get("stud");
$data['records'] = $query -> results();

And this is the view code

<!DOCTYPE html>
<html lang = "en">

<meta charset = "utf-8">
<title>Students Example</title>
<a href = "<?php echo base_url(); ?>


Currently not using the data coming from controller.
Any help will be highly appreciated. Thanks in advance.

Answer Source

You should use something like this

$data['records'] = $query -> result_array();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download