Неустранимая ошибка: вызов функции-члена на необъектном контроллере codeigniter

Вот мой контроллер 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 and 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 and 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 Data To Model
$this->insert->alum_insert($alumdata);
$this->load->view('registration_success');
}
}
}
?>

и вот моя модель aluminsert.php

<?php
class Aluminsert extends CI_Model{
function __construct() {
parent::__construct();
}
function alum_insert($alumdata){

$this->db->insert('user_detail', $alumdata);
}
}
?>

проверка формы работает, и после отправки формы отображается ошибка:
Неустранимая ошибка: вызов функции-члена alum_insert () для необъекта в C: \ wamp \ www \ ci \ application \ controllers \ profileinfo.php в строке 61

0

Решение

Ошибка заключается в коде ниже. Вы пытаетесь вызвать метод из класса insert, который в этом случае не существует в вашей модели.

$this->insert->alum_insert($alumdata);
$this->load->view('registration_success');

Ваша модель называется «Aluminsert», а метод, который вы используете для вставки, называется «alum_insert», поэтому вам лучше сделать это.

$this->aluminsert->alum_insert($alumdata);
$this->load->view('registration_success');
0

Другие решения

В codeigniter нам нужно загрузить базу данных. Так что есть два пути

  1. Либо вы можете загрузить его или
  2. Загружайте туда, где вам это нужно.

В autoload.php,Вы должны написать строку ниже.

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

ИЛИ ЖЕ

Другим способом вы также можете загрузить следующим образом:

$this->load->database();

Конечно, это поможет вам.

-1

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector