Welcome Guest, Not a member yet? Register   Sign In
I followed the news tutorial and got messed up.
#1

[eluser]Unknown[/eluser]
I am completely new to CodeIgniter so I went through the tutorial offered on the table of contents which came with CodeIgniter. I was doing great until I started to get this error when I tried to open the page.
Quote:A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\codeigniter\application\controllers\news.php:1)

Filename: libraries/Session.php

Line Number: 672

CodeIgniter 2 Tutorial

© 2011

I do not understand what this Warning is telling me.

Here is the code I had written according to the tutorial. There maybe there is an error somewhere in it.
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
          class News extends CI_Controller {

    public function __construct()
       {
           parent::__construct();
     $this->load->model('news_model');
    }
    
    
    public function index()
    {
     $data['news'] = $this->news_model->get_news();
     $data['title'] = 'News archive';
    
     $this->load->view('templates/header', $data);
     $this->load->view('news/index', $data);
     $this->load->view('templates/footer');
   }
  
     public function view($slug)
     {
        $data['news_item'] = $this->news_model->get_news($slug);
        
        if(empty($data['news_item']))
        {
         show_404();    
     }  
    
     $data['title'] = $data['news_item']['title'];
    
     $this->load->view('templates/header', $data);
     $this->load->view('news/view', $data);
     $this->load->view('templates/footer');
    
     }
  }
  
        
?>
All help greatly appreciated. :-)




Theme © iAndrew 2016 - Forum software by © MyBB