Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6763307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:27:37+00:00 2026-05-26T14:27:37+00:00

Having created my model, view and controller in an attempt to get data from

  • 0

Having created my model, view and controller in an attempt to get data from my database I receive an error and would like help finding out why I am receiving this error:

The error is as follows:

Severity: Notice

Message: Undefined property: How_can_we_help::$Content_model

Filename: controllers/how_can_we_help.php

Line Number: 14

I am trying to get my data by calling a function in my model, controller looks like:

class How_can_we_help extends CI_Controller {


    public function index()
    {
            //subcategory of page
          $data = array(
            'subcategory' => 'how_can_we_help',
        );

            //Get data from content table where subcategory = subcategory
             $data['pagecontent'] = $this->Content_model->getContent($data);

            //inserts "how_can_we_help" view into template
            $data['main_content'] = 'how_can_we_help';
            $this->load->view('includes/template', $data);
        }
}

I only want to retrieve data where the subcategory = how_can_we_help

Model:

class Content_model extends CI_Model {

        function getContent($data){

        $this->db->select('category, subcategory, title, intro, content, tags');
        $this->db->from('content');
        $this->db->where($data);

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

          if ($query->num_rows() > 0) {
            foreach ($query->result() as $row) {
                $data[] = $row;
            }

            return $data;
        }

    }

}

and finally the view

<?php 
foreach ($pagecontent->result() as $row)
{
 $title =  $row->title;
 $intro = $row->intro;
  $content = $row->content;
   $tags =  $row->tags;
}

;?>

Could somebody kindly show me the error of my ways.

The Batman

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:27:38+00:00Added an answer on May 26, 2026 at 2:27 pm

    DId you load your model before using it?

    Looks like CI mistakes the $this reference thinking it’s one of his method, while instead it refers to a model. Be sure you load the model in-time or autoload it in application/config/autoload.php:

    public function index()
    {
           //subcategory of page
              $data = array(
                'subcategory' => 'how_can_we_help',
            );
    
            $this->load->model('content_model');
    
            $data['pagecontent'] = $this->content_model->getContent($data);
       //...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Before iOS4, my app's initial view controller would check a passcode on/off settings variable
I am having difficulties implementing the codeigniter pagination class. I have created my model,
I'm having problems getting the new data from the RandomNumbers List I got this
I wanted to have more than one controller and view for same object/model in
I would like to use the same view for editing a blog post and
I have a view model with a from that includes a set of checkboxes.
I have created an MVC 3 view, just by adding a controller and scaffold
I use php and usually structure my application into model-view-controller so its always accessed
The issue I'm having is related to multiple models in a single controller/view in
I'm new to usercontrols, having only created one so far, so bear with me.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.