Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why I'm getting "cannot modify header information headers already sent by registration_model" error in codeigniter? [duplicate]

I have a problem with model in my codeigniter app. I'm getting this error of sending headers information. Basically, codeigniter is complaining about my registration model sending header information before anything else. How is it possible? I thought that models are only for holding db queries methods and nothing more. Can someone please explain me that?

This is how the beginning of a controller looks like:

function User()
{
    parent::Controller();
    $this->view_data['base_url'] = base_url();
    $this->load->model('User_registration_model');       // don't forget capital, it's important
    $this->load->model('user_map_model');                // don't forget capital, it's important
    $this->load->model('Tribe_model');                   // don't forget capital, it's important
    $this->load->library('email');                       // Loading email library
    $this->load->library('session');                     // sets up the session
    $this->load->library ('form_validation');            // Loading form validation library
    $this->load->helper(array('form', 'url'));  
}
like image 506
Pavel Avatar asked Aug 03 '10 08:08

Pavel


2 Answers

place this ob_start(); on first line of index.php under your application directory like this :

<?php
ob_start();
/*
 *---------------------------------------------------------------
 * APPLICATION ENVIRONMENT
 *---------------------------------------------------------------
like image 60
Gery Avatar answered Oct 19 '22 17:10

Gery


Note that headers should be sent before anything else. Make sure that there is no code/html or even space/indentation before the header function and there is nothing before the first opening php tag <?php as well as ending tag ?> in your view.

like image 34
Sarfraz Avatar answered Oct 19 '22 17:10

Sarfraz