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

i m trying code to to download excel file.
so i included file.
i have enabled hook=true in config file.
then in hook folder i created one file "Myclasses.php"
code of file like this

if (!defined('BASEPATH')) exit('No direct script access allowed');

class Myclasses
* includes the directory application\my_classes\Classes in your includes directory
function index()
//includes the directory application\my_classes\Classes\
ini_set('include_path', ini_get('include_path').';'.BASEPATH.'application/my_classes/Classes/');

in controller (admin_panel) i have written

but when i create object of my excel file in model like this
function testexcel($userid)
include 'PHPExcel.php';
echo date('H:iConfused') . " Create new PHPExcel object\n";
$objPHPExcel = new PHPExcel();
echo date('H:iConfused') . " Set properties\n";


when i run it gives me error like this
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\Mysimpleprofit\system\application\hooks\MyClasses.php:16)

Filename: libraries/Session.php

Line Number: 662

pls help me how to resolve such error...Its urgent.

You cannot echo. This will create headers before the actual excel headers, thus the error.

So do not echo in your controller or model.

i commented above echo line in model & clears cookie still it gives me same error.

in you hook file, do you have an extra space behind the closing php tag?

Anyway, it seems you hooks file is outputting some content. It might be a space or some error. Please check your error_log

[eluser]Phil Sturgeon[/eluser]
Don't even bother using a closing tag, best way to make sure you avoid this.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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