Welcome Guest, Not a member yet? Register   Sign In
Cannot modify header information - headers already sent
#1

[eluser]pallavi312[/eluser]
hello,
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


<?php
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
$this->load->library('session');

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";
$objPHPExcel->getProperties()->setCreator("BazZ");

}


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.
#2

[eluser]rogierb[/eluser]
You cannot echo. This will create headers before the actual excel headers, thus the error.

So do not echo in your controller or model.
#3

[eluser]pallavi312[/eluser]
hello,
i commented above echo line in model & clears cookie still it gives me same error.
#4

[eluser]rogierb[/eluser]
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
#5

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




Theme © iAndrew 2016 - Forum software by © MyBB