Welcome Guest, Not a member yet? Register   Sign In
error on the first page
#1

Hello,

Can anyone help me troubleshoot where the problem in my codes?

http://127.0.0.1/CompanyGiondaCI/

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


A PHP Error was encountered
Severity: Notice
Message: Undefined property: Mpages::$load
Filename: libraries/Form_validation.php
Line Number: 147
Backtrace:
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\models\mpages.php
Line: 10
Function: __construct
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\controllers\cpages.php
Line: 32
Function: model
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\index.php
Line: 315
Function: require_once

Fatal error: Call to a member function helper() on null in C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\system\libraries\Form_validation.php on line 147
A PHP Error was encountered
Severity: Error
Message: Call to a member function helper() on null
Filename: libraries/Form_validation.php
Line Number: 147
Backtrace:
" If I looks more intelligence please increase my reputation."
Reply
#2

(This post was last modified: 07-05-2016, 03:31 AM by wolfgang1983.)

(07-05-2016, 02:06 AM)davy_yg Wrote: Hello,

Can anyone help me troubleshoot where the problem in my codes?

http://127.0.0.1/CompanyGiondaCI/

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


A PHP Error was encountered
Severity: Notice
Message: Undefined property: Mpages::$load
Filename: libraries/Form_validation.php
Line Number: 147
Backtrace:
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\models\mpages.php
Line: 10
Function: __construct
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\controllers\cpages.php
Line: 32
Function: model
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\index.php
Line: 315
Function: require_once

Fatal error: Call to a member function helper() on null in C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\system\libraries\Form_validation.php on line 147
A PHP Error was encountered
Severity: Error
Message: Call to a member function helper() on null
Filename: libraries/Form_validation.php
Line Number: 147
Backtrace:

Make sure your class and file names have only the first letter upper case.

Make sure that cpages.php is like Cpages.php and same for class.

And don't leave your base url blank if your using CI3


PHP Code:
$config['base_url'] = ''


To
Code:
$config['base_url'] = 'http://localhost/your_project/';
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#3

I still do not understand why after fixing all these the same error still appears ?


models/mpages.php


PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

class 
Mpages extends CI_Controller {


    public function 
__construct()
    {
        
parent::__construct();
        
        
$this->load->database();
                
    } 



controllers/cpages.php


PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

class 
Cpages extends CI_Controller 



config/config.php


PHP Code:
$config['base_url'] = 'http://localhost/CompanyGiondaCI/'
" If I looks more intelligence please increase my reputation."
Reply
#4

For starters, Mpages should extend CI_Model, not CI_Controller, and the file names of your controllers and models need to have the first letter in upper case, matching the class names.

If your controller (Cpages) extends the constructor, it needs to call the parent constructor (as your model currently does).
Reply
#5

(This post was last modified: 07-11-2016, 03:48 AM by davy_yg.)

Hello,

I already fix couple things mentioned and still having that same problem remains.


A PHP Error was encountered
Severity: Notice
Message: Undefined property: Mpages::$load
Filename: libraries/Form_validation.php
Line Number: 147
Backtrace:
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\models\mpages.php
Line: 10
Function: __construct
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\controllers\cpages.php
Line: 32
Function: model
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\index.php
Line: 315
Function: require_once

Fatal error: Call to a member function helper() on null in C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\system\libraries\Form_validation.php on line 147
A PHP Error was encountered
Severity: Error
Message: Call to a member function helper() on null
Filename: libraries/Form_validation.php
Line Number: 147
Backtrace:


controllers/cpages.php


PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

class 
Cpages extends CI_Controller {

    
/**
     * Index Page for this controller.
     *
     * Maps to the following URL
     *         http://example.com/index.php/welcome
     *    - or -
     *         http://example.com/index.php/welcome/index
     *    - or -
     * Since this controller is set as the default controller in
     * config/routes.php, it's displayed at http://example.com/
     *
     * So any other public methods not prefixed with an underscore will
     * map to /index.php/welcome/<method_name>
     * @see https://codeigniter.com/user_guide/general/urls.html
     */
    
    
public function __construct()
    {
        
parent::__construct(); 



models/mpages.php


PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

class 
Mpages extends CI_Model {


    public function 
__construct()
    {
        
parent::__construct();
        
        
$this->load->database();
                
    }

    public function 
set_parentctg()
    { 
How to fix the error?
" If I looks more intelligence please increase my reputation."
Reply
Reply
#7

Your filenames in the error message still aren't correct (they should be Mpages.php and Cpages.php, rather than mpages.php and cpages.php).

A quick search on this error message indicates that it usually shows up when using HMVC or some test frameworks, though it might also show up when calling a controller from a controller without either of those in place (because you shouldn't call a controller from a controller).

In any case, you're not including enough code to track down the problem (you haven't even included the code that loads the form validation library), and your error messages still show other problems (which may not be related to this specific problem, but will probably cause other problems once you do get everything else working).
Reply




Theme © iAndrew 2016 - Forum software by © MyBB