Welcome Guest, Not a member yet? Register   Sign In
Teach me how to program
#1

(This post was last modified: 02-20-2016, 07:41 AM by ciadmin. Edit Reason: add more info )

A PHP Error was encountered
Severity: Notice
Message: Undefined property: Home::$page_model
Filename: controllers/home.php
Line Number: 14
Backtrace:
File: C:\xampp\htdocs\ci3\application\controllers\home.php
Line: 14
Function: _error_handler
File: C:\xampp\htdocs\ci3\index.php
Line: 292
Function: require_once


An uncaught Exception was encountered
Type: Error
Message: Call to a member function find_ID() on null
Filename: C:\xampp\htdocs\ci3\application\controllers\home.php
Line Number: 14
Backtrace:
File: C:\xampp\htdocs\ci3\index.php
Line: 292
Function: require_once


How to fix those error?

home.php

PHP Code:
$this->data['page_detail'] = $this->page_model->find_ID(); 

ci3/index.php

PHP Code:
require_once BASEPATH.'core/CodeIgniter.php'

Why the error appears?

models/page_model.php

PHP Code:
public function find_ID($post_ID false)
    {
        $this->db->select('post.*, template.*');
        $this->db->from('post');
        $this->db->join('template''template.template_ID = post.post_template_ID''left');
        if ($post_ID)
            $this->db->where(array('post.post_type' => 'page''post.post_ID' => $post_ID'post.post_status' => 1));
        else
        
{
            $this->db->where(array('post.post_type' => 'page''post.post_status' => 1));
            $this->db->order_by('post.post_position');
        }
        $this->db->limit(1);
        $q $this->db->get();
        
        if
($q->num_rows() > 0)
            return $q->row();
        
        return false
;
    
" If I looks more intelligence please increase my reputation."
Reply
#2

Are you loading the page model?

$this->load->model('page_model')
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply
#3

Okay, here I have a new error that I am dealing with:


A PHP Error was encountered

Severity: Notice

Message: Undefined property: Home::$db

Filename: core/Model.php

Line Number: 77

Backtrace:

File: C:\xampp\htdocs\ci3\application\models\page_model.php
Line: 80
Function: __get

File: C:\xampp\htdocs\ci3\application\controllers\home.php
Line: 15
Function: find_ID

File: C:\xampp\htdocs\ci3\index.php
Line: 292
Function: require_once

-----------------------------------------

An uncaught Exception was encountered

Type: Error

Message: Call to a member function select() on null

Filename: C:\xampp\htdocs\ci3\application\models\page_model.php

Line Number: 80

Backtrace:

File: C:\xampp\htdocs\ci3\application\controllers\home.php
Line: 15
Function: find_ID

File: C:\xampp\htdocs\ci3\index.php
Line: 292
Function: require_once

--------------------------------


page_model.php


PHP Code:
public function find_ID($post_ID false)
    {
        $this->db->select('post.*, template.*');
        $this->db->from('post');
        $this->db->join('template''template.template_ID = post.post_template_ID''left');
        if ($post_ID)
            $this->db->where(array('post.post_type' => 'page''post.post_ID' => $post_ID'post.post_status' => 1));
        else
        
{
            $this->db->where(array('post.post_type' => 'page''post.post_status' => 1));
            $this->db->order_by('post.post_position');
        }
        $this->db->limit(1);
        $q $this->db->get();
        
        if
($q->num_rows() > 0)
            return $q->row();
        
        return false
;
    

line 80:  $this->db->select('post.*, template.*');

controllers/home.php


PHP Code:
public function index()
    {
        $this->load->model('page_model');
        $this->data['page_detail'] = $this->page_model->find_ID();
        
        $this
->page_model->counter($this->data['page_detail']->post_ID);
        
        $this
->data['post_list'] = $this->model->post($this->data['page_detail']->post_ID);
        $this->data['gallery_list'] = $this->model->post($this->data['page_detail']->post_IDtrue);
        
        $this
->load->view($this->data['page_detail']->template_name$this->data);
    


line 15:      $this->data['page_detail'] = $this->page_model->find_ID();

index.php

PHP Code:
require_once BASEPATH.'core/CodeIgniter.php'

Can you help me fix the error?
" If I looks more intelligence please increase my reputation."
Reply
#4

You should connect to the database http://www.codeigniter.com/user_guide/da...r-database
Reply
#5

... and also learn that we're not your personal debugging tool.
Reply
#6

How do I know if my CI already connected to the database or not?

database.php

PHP Code:
$db['default'] = array(
 
   'dsn'    => '',
 
   'hostname' => 'localhost',
 
   'username' => 'gsaconst_admin',
 
   'password' => 'spesialiskonstruksi1',
 
   'database' => 'gsaconst_database',
 
   'dbdriver' => 'mysqli_connect',
 
   'dbprefix' => 'pix_',
 
   'pconnect' => TRUE,
 
   'db_debug' => (ENVIRONMENT !== 'production'),
 
   'cache_on' => FALSE,
 
   'cachedir' => '',
 
   'char_set' => 'utf8',
 
   'dbcollat' => 'utf8_general_ci',
 
   'swap_pre' => '',
 
   'encrypt' => FALSE,
 
   'compress' => FALSE,
 
   'stricton' => FALSE,
 
   'failover' => array(),
 
   'save_queries' => TRUE
); 


oh well ... sorry.. I am considering myself a beginner in CI.  I need some help from experts.  Thanks in advance.
" If I looks more intelligence please increase my reputation."
Reply
#7

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Home::$db

Filename: core/Model.php

Line Number: 77

-------------------------

core/Model.php

PHP Code:
public function __get($key)
    {
        
// Debugging note:
        //    If you're here because you're getting an error message
        //    saying 'Undefined Property: system/core/Model.php', it's
        //    most likely a typo in your model code.
        
return get_instance()->$key;
    } 


line 77:  return get_instance()->$key;
" If I looks more intelligence please increase my reputation."
Reply
#8

I think you need make sure you are loading the DB library.

I would recommend you reading through all the CI documentation first. It's extremely well written, easy to follow, and will probably prevent the next few posts you were going to make.

If you follow the guide, you will be able to connect to the db, execute a sql query and parse the results.
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply
#9

i have so much sympathy for people who try and build first without doing the tutorial because thats how i was.
but seriously -- do the tutorial. and don't just paste the code and get it working but really step through and learn each step.
you will save yourself so much time.
Reply
#10

(This post was last modified: 02-14-2016, 07:03 PM by freddy.)

well all you need copy paste your error in google, you need to autoload database just goes to your config/autoload.php then add database, look at me here

Code:
$autoload['libraries'] = array('database'); //you need to autoload it !
Reply




Theme © iAndrew 2016 - Forum software by © MyBB