Saturday 15 March 2014

php - Fatal error: Call to a member function, on a non-object, codeigniter controller -



php - Fatal error: Call to a member function, on a non-object, codeigniter controller -

here's controller profileinfo.php

<?php class profileinfo extends ci_controller { function index() { $this->load->helper(array('form', 'url')); $this->load->model('aluminsert','', true); $this->load->library('form_validation'); $this->form_validation->set_rules('name', 'name', 'required'); $this->form_validation->set_rules('branch', 'bramch', 'required'); $this->form_validation->set_rules('academicinterest', 'academic interest', 'required'); $this->form_validation->set_rules('internshipdetail', 'internship details', 'required'); $this->form_validation->set_rules('interest_hobbies', 'interest , hobbies', 'required'); $this->form_validation->set_rules('personalblog', 'personal blog', 'required'); $this->form_validation->set_rules('facebookprofile', 'facebook profile', 'required'); $this->form_validation->set_rules('linkedinprofile', 'linkedin profile', 'required'); $this->form_validation->set_rules('homecity', 'home city', 'required'); $this->form_validation->set_rules('country', 'country', 'required'); $this->form_validation->set_rules('higherdegree', 'higher degree', 'required'); $this->form_validation->set_rules('collegeofeducation', 'college of education', 'required'); $this->form_validation->set_rules('officialemail', 'official email', 'required'); $this->form_validation->set_rules('careerinterests', 'career interest', 'required'); $this->form_validation->set_rules('presentemployer', 'present employer', 'required'); $this->form_validation->set_rules('presentjob', 'present job', 'required'); $this->form_validation->set_rules('previousemployer', 'previous employee', 'required'); $this->form_validation->set_rules('startupname', 'startup name', 'required'); if ($this->form_validation->run() == false) { $this->load->view('alumprofile'); } else { $alumdata = array( 'name' => $this->input->post('name'), 'branch' => $this->input->post('branch'), 'academic interest' => $this->input->post('academicinterest'), 'internship details' => $this->input->post('internshipdetail'), 'interest , hobbies' => $this->input->post('interest_hobbies'), 'personalblog' => $this->input->post('personalblog'), 'facebook profile' => $this->input->post('facebookprofile'), 'linkedin profile' => $this->input->post('linkedinprofile'), 'home city' => $this->input->post('homecity'), 'country' => $this->input->post('country'), 'higher degree' => $this->input->post('higherdegree'), 'college of education' => $this->input->post('collegeofeducation'), 'official email' => $this->input->post('officialmail'), 'career interest' => $this->input->post('careerinterests'), 'present employer' => $this->input->post('presentemployer'), 'present job' => $this->input->post('presentjob'), 'previous employee' => $this->input->post('previousemployer'), 'startup name' => $this->input->post('startupname'), ); // transfering info model $this->insert->alum_insert($alumdata); $this->load->view('registration_success'); } } } ?>

and here's model aluminsert.php

<?php class aluminsert extends ci_model{ function __construct() { parent::__construct(); } function alum_insert($alumdata){ $this->db->insert('user_detail', $alumdata); } } ?>

form validation working , after submitting form, error shown is: fatal error: phone call fellow member function alum_insert() on non-object in c:\wamp\www\ci\application\controllers\profileinfo.php on line 61

in codeigniter need load database. there 2 ways

either can autoload or load ever need it.

in autoload.php,you have write below line.

$autoload['libraries'] = array('database');

or

in other manner can load in next manner :-

$this->load->database();

surely help you.

php database codeigniter codeigniter-2

No comments:

Post a Comment