Welcome Guest, Not a member yet? Register   Sign In
Problem with redirect when model have been loaded
#1

[eluser]KusTov[/eluser]
Hello
I want to load model before I do redirect, and get an error:

Severity: Warning
Message: Cannot modify header information - headers already sent by (file name)
Filename: helpers/url_helper.php
Line Number: 455


Code:
function update_brand(){
  $this->load->model('Brand');
  /* Some code goes here */

  redirect('class_name/func_name/id/444'.$id);
}
#2

[eluser]Grahack[/eluser]
This is because some output has been done before redirecting. Maybe you 'echoed' something before or you have white space outside the <?php and ?> tags.

EDIT: Welcome here !!!
#3

[eluser]KusTov[/eluser]
[quote author="Grahack" date="1202311387"]This is because some output has been done before redirecting. Maybe you 'echoed' something before or you have white space outside the <?php and ?> tags.

EDIT: Welcome here !!![/quote]

No, there is no output in this function and there is no white space in model file.
Maybe post data can cause it?
I do
Code:
$showin = $this->input->post('showin');
into the function .
#4

[eluser]Grahack[/eluser]
My guess is it's not related to post data. Not only the model file is parsed, check out your controller for example.
#5

[eluser]KusTov[/eluser]
[quote author="Grahack" date="1202312120"]My guess is it's not related to post data. Not only the model file is parsed, check out your controller for example.[/quote]

This happens only if I load the model. If I do it without loading the model(move functions from model to controller) there is no problem ...
#6

[eluser]Seppo[/eluser]
Read the error message. You must be getting something like
Quote:Warning: Cannot modify header information - headers already sent by (output started at /path/to/dir/test.php:2) in /path/to/dir/test.php on line 3

The output started at points to the line where the problem is.
#7

[eluser]KusTov[/eluser]
[quote author="Seppo" date="1202318761"]Read the error message. You must be getting something like
Quote:Warning: Cannot modify header information - headers already sent by (output started at /path/to/dir/test.php:2) in /path/to/dir/test.php on line 3

The output started at points to the line where the problem is.[/quote]

It says :
Message: Cannot modify header information - headers already sent by (output started at path/system/application/models/brand.php:1)

But there no white spaces the file beginning at:
Code:
<?php
class Brand extends Model
{

It happens so with other model files...
Thanks
#8

[eluser]Grahack[/eluser]
Sometimes, this problem arises because of encoding. I can't be more precise but try to check the character encoding of your file (utf8 vs ISO-xxxx, ...).
#9

[eluser]KusTov[/eluser]
It really was some invisible characters before
Code:
<?php
that my editor added , I removed it in Pico.
Thanks.




Theme © iAndrew 2016 - Forum software by © MyBB