• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cannot modify header information - headers already sent by...?

Hi guys

How do i fix this error below?

This is the controller welcome.php
class Welcome extends Controller {

    function Welcome(){
    function index(){
        $data['title'] = "Welcome to our Site";
        $data['headline'] = "";
        $data['include'] = 'home';
    function contactus(){
        if ($this->input->post('email')){
    function thankyou(){
        $data['title'] = "Thank You!";
        $data['headline'] = "Thanks!";
        $data['include'] = 'thanks';

/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */

This is the model below mcontacts.php
class MContacts extends Model{

    function MContacts(){

     function addContact(){
        $now = date("Y-m-d H:i:s");
        $data = array(
            'name' => $this->input->xss_clean($this->input->post('name')),
            'email' => $this->input->xss_clean($this->input->post('email')),
            'notes' => $this->input->xss_clean($this->input->post('notes')),
            'ipaddress' => $this->input->ip_address(),
            'stamp' => $now

        $this->db->insert('contacts', $data);    

I hope someone can give me good advice for this.
Thank you in advanced.

Check your mcontacts.php file and make sure you don't have any extra spaces or linebreaks or anything after the PHP closing tag. The closing tag should be the very last thing in the file.

I don't think that you should have a closing tag in your model: http://ellislab.com/codeigniter/user-gui...losing_tag

@Vega - Although you've hit a valid point that will ultimately provide a superficial solution to the problem of whitespace after the closing tag, and although it's "recommended practice", the omission of closing tags (even in PHP-only files) just doesn't seem like a proper solution. To me, it's kind of like turning error reporting off on warnings and notices to not be bothered with non-fatal issues an application might have just to be able to continue with bad programming practices.


Thank you very much.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.