![]() |
Message: Undefined property: Mainpage::$3 - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Message: Undefined property: Mainpage::$3 (/showthread.php?tid=60946) |
Message: Undefined property: Mainpage::$3 - El Forum - 08-07-2014 [eluser]signals107[/eluser] hi , i faced to this error in my project: Severity: Notice Message: Undefined property: Mainpage::$3 Filename: core/Model.php Line Number: 51 what is the fault? please guide me. Message: Undefined property: Mainpage::$3 - El Forum - 08-07-2014 [eluser]Tpojka[/eluser] What says line 51 in core/Model.php file? Message: Undefined property: Mainpage::$3 - El Forum - 08-07-2014 [eluser]signals107[/eluser] 48 : function __get($key) 49: { 50: $CI =& get_instance(); 51: return $CI->$key; 52: } Message: Undefined property: Mainpage::$3 - El Forum - 08-07-2014 [eluser]CroNiX[/eluser] The problem is in the Mainpage model, not the base model class. You have a variable/property named $3, which is illegal in php. Variables can't start with a number. Message: Undefined property: Mainpage::$3 - El Forum - 08-07-2014 [eluser]signals107[/eluser] the point is i have not any variable that start with number! i read my files over and over and i did not find any variable such that Message: Undefined property: Mainpage::$3 - El Forum - 08-07-2014 [eluser]Tpojka[/eluser] You are getting some $key. Is it set before in code? Message: Undefined property: Mainpage::$3 - El Forum - 08-07-2014 [eluser]signals107[/eluser] what do you mean? Message: Undefined property: Mainpage::$3 - El Forum - 08-07-2014 [eluser]CroNiX[/eluser] We're not going to be able to guess. We need to see the code for the controller/method that is calling your mainpage model, as well as the model itself. Message: Undefined property: Mainpage::$3 - El Forum - 08-07-2014 [eluser]signals107[/eluser] this is my controller/mainpage.php: <?php class Mainpage extends CI_Controller { public function _construct(){ parent::_construct(); } public function index($page='mainpage'){ if ( ! file_exists(APPPATH.'/views/pages/'.$page.'.php')){ show_404(); } $data['title'] = ucfirst($page); $this->load->view('Templates/header',$data); $this->load->view('pages/'.$page,$data); } public function login_user(){ $this->load->helper('form'); $this->load->library('form_validation'); $this->form_validation->set_rules('username','Username','required|callback_check_valid|trim'); $this->form_validation->set_rules('password','Password','required|callback_check_valid|trim'); if($this->form_validation->run()===FALSE){ $data['title'] = ucfirst('mainpage'); $this->load->view('Templates/header',$data); $this->load->view('pages/mainpage.php',$data); return true; } // call model function $this->load->model('user_model'); $bool=$this->user_model->login(); if($bool===true){ echo "you are login!"; return true; //redirect('page after login');// show main page } else{ $data['title'] = ucfirst('mainpage'); $this->load->view('Templates/header',$data); $this->load->view('pages/mainpage.php',$data); echo "your username or password is wrong!"; return false; } } function check_valid($s){ $this->load->helper('string'); $s=strip_quotes($s); $s=trim_slashes($s); return true; } } |