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 8587643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:37:04+00:00 2026-06-11T22:37:04+00:00

I am following the tutorial from the Codeigniter website about making a news section.

  • 0

I am following the tutorial from the Codeigniter website about making a news section. Right now I am getting an undefined property message on line 13.

Here is my model. applications/models/articles_model

<?php

class Articles_model extends CI_Model{

    public function __construct(){

        $this->load->database();
    }

    public function get_article($slug = False){

        if ($slug === FALSE){

             $query = $this->db->get('articles');
             return $query->result_array();
        }

        $query = $this->db->get('articles');
        return $query->result_array();
    }

    $query = $this->db->get_where('articles', array('slug' => $slug));
    return $query->row_array();
}

And here is the controller. applications/controllers/articles.php

<?php

class Articles extends CI_Controller{

    public function __contruct(){

        parent::__construct();
        $this->load->model('Articles_model');
    }

    public function index(){

        //Message: Undefined property Articles::Articles_model    
        $data['articles'] = $this->Articles_model->get_article();
        $data['title'] = "Archive";

        $this->load->view('templates/header', $data);
        $this->load->view('articles/index', $data);
        $this->load->view('templates/footer');
    }

    public function view($slug){

        $data['articles'] = $this->Articles_model->get_article($slug);

        if(empty($data['articles'])){

            show_404();
        }

        $data['title'] = $data['articles']['title'];

        $this->load->view('templates/header', $data);
        $this->load->view('articles/view', $data);
        $this->load->view('templates/footer');
    }
}

These are all the routes I have setup. applications/config/routes.php

$route['articles/(:any)'] = 'articles/view/$1';
$route['articles'] = 'articles';
$route['default_controller'] = 'pages/view';
$route['(:any)'] = 'pages/view/$1';

My database looks like this

mysql> describe articles
+-------+--------------+------+-----+---------+----------------+
| Field | Type         | Null | Key | Default | Extra          |
+-------+--------------+------+-----+---------+----------------+
| id    | int(11)      | NO   | PRI | NULL    | auto_increment |
| title | varchar(128) | NO   |     | NULL    |                |
| slug  | varchar(128) | NO   | MUL | NULL    |                |
| text  | text         | NO   |     | NULL    |                |
+-------+--------------+------+-----+---------+----------------+

I have tried using the property with a capital first-letter,$this->Articles_model, and not, $this->articles_model.

Am I missing something stupid?
If so what is it?
If it’s not stupid how can I debug?

EDIT

The ouput of print_r, as per comments, did not contain “Articles_model”. The first tier thing is over my head, but CTRL-F isn’t. Also the Apache logs mention this…

[Sun Sep 23 13:19:30 2012] [error] [client 127.0.0.1] PHP Fatal error:  Call to a member function get_article() on a non-object in /home/noel/dev/web/
ci/CodeIgniter_2.1.2/application/controllers/articles.php on line 13

EDIT1

I thought I fixed it, but no, see the comment on my answer. For some reason $this->article_model is not an object.

Why? I’ve been to one World Fair, a Picnic and a Rodeo and that’s the stupidest thing I ever heard come over a set of earphones. You sure you got today’s codes?

  • 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-06-11T22:37:06+00:00Added an answer on June 11, 2026 at 10:37 pm

    Had a closer look and the answer is very simple: Try changing this line:

    public function __contruct(){
    

    to this:

    public function __construct(){
    

    😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm following the Getting started tutorial from the Boost website. I'm trying to build
Following from this tutorial.. http://net.tutsplus.com/articles/news/codeigniter-from-scratch-day-6-login/ I have successfully implemented and created/logged in users.. I
I'am following a tutorial from Facebook for making a mobile website application. But i
I been following a tutorial for making my webpage css 100% height from this
I am following Django tutorial from django website. There I see a regular expression
I am getting this error while following the tutorial from railstutorial.org. Model class :
I've tried to get trough the following tutorial Making Operating System Calls from SQL
I am following a tutorial from netuts about raphael js and I dont understand
I'm following the tutorial from androiddevelopers website. I copied the code and mTabHost is
Following a tutorial from iTunes U on how to do face detection (the tutorial

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.