Welcome Guest, Not a member yet? Register   Sign In
What is wrong with this code? Why the language doesn't load?
#1

[eluser]ReyPM[/eluser]
Hi every:
I'm trying to load a language files but I'm getting this error:
Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined property: User::$lang
Filename: controllers/user.php
Line Number: 6
Where line number 6 is this:
Code:
5  public function __construct() {
6        $this->lang->load('common');
7        $this->lang->load('user');
8  }
What's wrong here?
Cheers and thx
#2

[eluser]InsiteFX[/eluser]
Try loading the Language class and Language_helper!

InsiteFX
#3

[eluser]ReyPM[/eluser]
You mean in autoload? This:
Code:
$autoload['libraries'] = array('database','session','language','my_usession','encryptdecrypt');
$autoload['language'] = array('spanish');
Doesn't work too
#4

[eluser]Unknown[/eluser]
Hi,

try this:

Code:
public function __construct() {
      $this->load->helper('language');

      $this->lang->load('common');
      $this->lang->load('user');
}
#5

[eluser]InsiteFX[/eluser]
Show the structure of your application/language Directories!

InsiteFX
#6

[eluser]ReyPM[/eluser]
This is the structure of my application/language folder:

- english
index.html
- spanish
common_lang.php
index.html
user_lang.php
#7

[eluser]ReyPM[/eluser]
Well something is really wrong here because I tried to load another library and get the same error:
Quote:Severity: Notice
Message: Undefined property: Brands::$load
Filename: controllers/brands.php
Line Number: 5
The file brands.php is as follow:
Code:
<?php

class Brands extends CI_Controller {
   public function __construct() {
      $this->load->helper('flexigrid');
   }
  
   public function index() {
      if (!$this->my_usession->logged_in) {
         redirect('user/login');
      }
      $data['title'] = 'Admin Brands';
      $this->load->view('brands/index', $data);
   }
  
}
I'm using Code Igniter 2.0.1 in XAMPP for Windows 7
#8

[eluser]ReyPM[/eluser]
Well I found the error just need to inherit from Controller constructor:
Code:
public function __construct() {
      parent::__construct();
      $this->load->helper('flexigrid');
}




Theme © iAndrew 2016 - Forum software by © MyBB