CodeIgniter Forums
error on the first page - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: error on the first page (/thread-65638.html)



error on the first page - davy_yg - 07-05-2016

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:


RE: error on the first page - wolfgang1983 - 07-05-2016

(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/';



RE: error on the first page - davy_yg - 07-05-2016

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/'



RE: error on the first page - mwhitney - 07-07-2016

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).


RE: error on the first page - davy_yg - 07-11-2016

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?


RE: error on the first page - JayAdra - 07-11-2016

http://lmgtfy.com/?q=learn+php
http://lmgtfy.com/?q=php+error+undefined+property


RE: error on the first page - mwhitney - 07-11-2016

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).