CodeIgniter Forums
Help! Message: Cannot modify header information - headers already sent by - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Help! Message: Cannot modify header information - headers already sent by (/showthread.php?tid=52300)



Help! Message: Cannot modify header information - headers already sent by - El Forum - 06-05-2012

[eluser]josepichu[/eluser]
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/ebconsul/public_html/guaguas/application/models/estados_model.php:1)

Filename: helpers/url_helper.php

Line Number: 546

...


my estados_model.php file is this:

Code:
<?php

class Estados_model extends CI_Model {

function __construct() {

  parent::__construct();


}

function guardar_cambio_estado($e_fuente, $e_destino, $idincidencia) {

  $ip = $_SERVER['REMOTE_ADDR'];
  //$ip = $this->input->ip_address();

  $sql = "insert into historial_cambios_estados set idincidencia='".$idincidencia."', estado_fuente='".$e_fuente."', ";
  $sql .= "estado_destino='".$e_destino."', fecha_cambio_estado='".date("Y-m-d H:i:s")."', ";
  $sql .= "usuario='".$this->session->userdata('usuario')."', ip='".$ip."'";
  
  mysql_query($sql);
  
  return 0;  
  
}

}

?>

It hasn't space before the <?php...


Help! Message: Cannot modify header information - headers already sent by - El Forum - 06-05-2012

[eluser]CroNiX[/eluser]
Try removing the last php ending tag at the bottom of the page. They aren't needed and cause problems if there is anything after it, like a space. So it's best to just leave them off, like each file of the framework does.


Help! Message: Cannot modify header information - headers already sent by - El Forum - 06-05-2012

[eluser]Ayeyermaw[/eluser]
remove
Code:
?>

from the bottom of your file. Also make sure that there are no spaces or lines before
Code:
<?php

Does that fix it?


Help! Message: Cannot modify header information - headers already sent by - El Forum - 06-05-2012

[eluser]josepichu[/eluser]
Thanks, but I have checked all You say but the message doesn't disappear.

It's strange because in localhost i don't have the warning message.

Anyway, I call estados_model.php from another method (guaguas_model.php). I'm thinking to include the method code inside guaguas_model.php... xD.





Help! Message: Cannot modify header information - headers already sent by - El Forum - 06-05-2012

[eluser]WanWizard[/eluser]
You should not only check the current file, but every file that is loaded by the request, for anything preceding
Code:
<?php



Help! Message: Cannot modify header information - headers already sent by - El Forum - 06-05-2012

[eluser]Ayeyermaw[/eluser]
You definately removed ?> from the end of your file?




Help! Message: Cannot modify header information - headers already sent by - El Forum - 06-05-2012

[eluser]josepichu[/eluser]
[quote author="CroNiX" date="1338923679"]Try removing the last php ending tag at the bottom of the page. They aren't needed and cause problems if there is anything after it, like a space. So it's best to just leave them off, like each file of the framework does.[/quote]

mmm... i have in all my controllers the last php tag in the page bottom. Can be these the problem? I don't think so, because so far have had no problems.


Help! Message: Cannot modify header information - headers already sent by - El Forum - 06-05-2012

[eluser]josepichu[/eluser]
[quote author="Ayeyermaw" date="1338926897"]You definately removed ?> from the end of your file?

[/quote]

Yes, in the model only... i will try to remove it in the controllers too.


Help! Message: Cannot modify header information - headers already sent by - El Forum - 06-05-2012

[eluser]CroNiX[/eluser]
Remove them from all files. They are already removed from the files that come with CI. And I'd do as WanWizard suggested and check for anything before php open tag at beginning of the file. On all files you have created.

One other thing that can cause that, depending on what you're doing, is echoing straight from the controller instead of a view, because that will show up before any of the view files as it's unbuffered.