0

I have already read like half a dozen similar questions here, and already double checked that there are no white spaces before <?php or after ?> in my library.

Ok note that I get this error RANDOMLY. When I am on the page and press CTRL+R (refresh) multiple times, for like 2 or 3 consecutive tries, the error message is not there, and then the error message comes and stays for a few more tries..

the exact error message I am getting is

<h4>A PHP Error was encountered</h4>

<p>Severity: Warning</p>
<p>Message:  Cannot modify header information - headers already sent by (output started at A:\work\fast\semi 6\software engineering\project\project2\main\repo\main_proj\application\config\admin_template.php:2)</p>
<p>Filename: libraries/Session.php</p>
<p>Line Number: 672</p>

So obviously the culprit seems to be the admin_template.php library file..

my controller function that calls the library:

 public function view_items(){
    $this->session->set_userdata('f');
    $table="F";
    $this->admin_template->display_direct($table,'');
    }

I am copying the file here

note that <?php is at line 1

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Admin_template{

    private
    $selected_item=-1,

    $menu=
        array(
        'Items'=>
            array(
              'Add Item'=>'admin/items/add_item',
              'View Items'=>'admin/items/view_items',

            ),
        'Administration'=>
            array(
                'View Admins'=>'admin/administration/view_admins',
                'View Representatives'=>'admin/administration/view_representative'
            )
        );


    public function __construct(){
    foreach($this->menu as $key=>$items){
        $this->menu[$key]['size']=sizeof($items);
    }
    $this->ci=&get_instance();
    }

    public function display_direct($view){
    $admin_template_data=array();
    $admin_template_data['content']=$view;
    $admin_template_data['heading']="heading";
    $admin_template_data['menu']=$this->menu;
    $admin_template_data['selected_item']=1;//$this->get_selected_item();

    return $this->ci->load->view('admin/main_template',$admin_template_data);
    }


}
Ahmed-Anas
  • 5,471
  • 9
  • 50
  • 72
  • The level of hierarchy :O – hjpotter92 Apr 20 '13 at 17:38
  • lol..but thats irrelevent.. any ways ok this is REALLY weird.. I renamed admin_template to a_temp and it worked now! renamed it back to admin_template, same problem. Then renamed it to admin_tmpl and its working again... wtf :S – Ahmed-Anas Apr 20 '13 at 17:40
  • Check your PHP and/or CI error logs. It looks like a PHP error is occurring which is causing text to be output to the browser before HTTP headers are sent. You need to find out what that error is so it can be fixed. – kittycat Apr 20 '13 at 18:02
  • nope.. php log is empty. CI log only has the header already sent error.... – Ahmed-Anas Apr 20 '13 at 18:19
  • Are you using CI database sessions? If so, temporarily change it to CI native PHP sessions and see if problem persists. You may be having database connectivity issues. – kittycat Apr 20 '13 at 18:49
  • yup. using CI database sessions.. How do you change them to native ? – Ahmed-Anas Apr 21 '13 at 07:29
  • Do you use a linux server? It could be the case there are two files with capital and small name. – Nish Apr 22 '13 at 08:08

0 Answers0