Welcome Guest, Not a member yet? Register   Sign In
header already sent ERROR from unexpected show_php_error function
#1

[eluser]J. Manuel[/eluser]
the link that start the process i need to fix is:

INFO - 2011-03-11 14:15:26 --&gt; <a location='/es/downloads/genera_mobile/6773'><img src="http://portal.localhost/images/kmlmobile.png" alt="Descargar Archivo KML(Google Earth)" title="Descargar Archivo KML(Google Earth)" border="0" style="float:left;" /></a>

So, genera_mobile method is called.

This method is like that:
function genera_mobile($id_terminal)
{
return $this->gkml->genera_mobile($id_terminal);
}



genera_mobile method at gkml library is:
function genera_mobile($idterminal)
{
$CI =& get_instance();
$CI->load->model('modelo_kml');
$CI->load->language('downloads');

$CI->load->library('Session');

$session_id = $CI->session->userdata('session_id');
$retornado = $CI->modelo_kml->_terminal($idterminal)->result_array();
$this->file = $this->xml_start."\r\n";
$this->file .= $this->cab_movil."\r\n";
$this->file .= '<Document>'."\r\n";
$this->file .= $this->terminal_movil($idterminal,$retornado[0]['name'],$session_id);
$this->file .= '</Document>'."\r\n";
$this->file .= '</kml>'."\r\n";
print $this->download_kml($this->file,'mobile_terminal_'.$retornado[0]['name']);
}

print $this->download_kml($this->file,'mobile_terminal_'.$retornado[0]['name']); line is where the error is.

The script might download the generated file ($this->file)
The file downloaded is:

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
<kml >
<Document>
<NetworkLink id="6773">
<name>META</name>
<flyToView>1</flyToView>
&lt;Link&gt;
<href>http://portal.localhost/downloads/kml_mobile/6773/2949cda11484a8c93c16f41d8f3810ea</href>
<refreshMode>onInterval</refreshMode>
<refreshInterval>60</refreshInterval>
&lt;/Link&gt;
</NetworkLink>
</Document>
</kml>
<br />
<b>Fatal error</b>: ob_start() [&lt;a href='ref.outcontrol'&gt;ref.outcontrol&lt;/a&gt;]: Cannot use output buffering in output buffering display handlers in <b>/var/www/trunk/system/libraries/Exceptions.php</b> on line <b>161</b><br />

All is right, instead the last error line attached at the end of the downloaded file. I can't figure out the reason and solve this error.

that line is created by an internal codeigniter error handler, I examined the error description deeper and I got the error is:

INFO - 2011-03-11 13:19:40 --&gt; Cannot modify header information - headers already sent by (output started at /var/www/trunk/system/application/libraries/Gkml.php:305)


This line 305 is the one I mentioned before:
function genera_mobile($idterminal)
{
...
print $this->download_kml($this->file,'mobile_terminal_'.$retornado[0]['name']);
}


And this is the download_kml funcion.

function download_kml($file,$name = 'googleearth')
{
$fsize = mb_strlen($file);
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: application/vnd.google-earth.kml+xml");
header("Content-Disposition: attachment; filename=$name.kml");
header("Content-Transfer-Encoding: quoted-printable");
header("Content-Length: " . $fsize);
return $this->file;
}

I can't figure out why ...

Thank you very much for your time !
#2

[eluser]InsiteFX[/eluser]
Edit your post and use the code tags! makes it a lot easier for us to view it.

Code:
// Open code tag
// [code]
// your code here

// ending code tag
// [forward slash code]

Or use POST REPLY

InsiteFX
#3

[eluser]J. Manuel[/eluser]
Hello,

Thank you for reading my post and help to improve my communication. I can understand very well what did you say so I am reposting it following your indications.

It's very annoying to me. I was two days trying to figure out what is sending header information before. Now I fell confused and blocked... still researching ...

Please, any expert-watch-feedback will be really appreciate. If you think you need to examine more code or do you need more information from my side, don't hesitate to contact me.

Thank you in advance for your time.

--- Re-POST here ---
the link that start the process i need to fix is:

INFO - 2011-03-11 14:15:26—> <a >http://portal.localhost/images/kmlmobile.png</a>

So, genera_mobile method is called.

This method is like that:
Code:
function genera_mobile($id_terminal)
  {
      return $this->gkml->genera_mobile($id_terminal);
  }

where genera_mobile method at gkml library is:
Code:
function genera_mobile($idterminal)
  {
      $CI =& get_instance();
      $CI->load->model(‘modelo_kml’);
      $CI->load->language(‘downloads’);
    
      $CI->load->library(‘Session’);

      $session_id = $CI->session->userdata(‘session_id’);
      $retornado = $CI->modelo_kml->_terminal($idterminal)->result_array();
      $this->file = $this->xml_start.”\r\n”;
      $this->file .= $this->cab_movil.”\r\n”;
      $this->file .= ‘<Document>’.”\r\n”;
      $this->file .= $this->terminal_movil($idterminal,$retornado[0][‘name’],$session_id);
      $this->file .= ‘</Document>’.”\r\n”;
      $this->file .= ‘</kml>’.”\r\n”;
      print $this->download_kml($this->file,‘mobile_terminal_’.$retornado[0][‘name’]);
  }

print $this->download_kml($this->file,‘mobile_terminal_’.$retornado[0][‘name’]); line is where the error is.

The script might download the generated file ($this->file)
The file downloaded is:

Code:
&lt;?xml version=“1.0” encoding=“UTF-8”?&gt;
<kml >
<Document>
<NetworkLink id=“6773”>
<name>META</name>
<flyToView>1</flyToView>
&lt;Link&gt;
<href>http://portal.localhost/downloads/kml_mobile/6773/2949cda11484a8c93c16f41d8f3810ea</href>
<refreshMode>onInterval</refreshMode>
<refreshInterval>60</refreshInterval>
&lt;/Link&gt;
</NetworkLink>
</Document>
</kml>


Fatal error:  ob_start() [<a >ref.outcontrol</a>]: Cannot use output buffering in output buffering display handlers in /var/www/trunk/system/libraries/Exceptions.php on line 161

All is right, instead the last error line attached at the end of the downloaded file. I can’t figure out the reason and solve this error.

that line is created by an internal codeigniter error handler, I examined the error description deeper and I got the error is:

Code:
INFO - 2011-03-11 13:19:40—> Cannot modify header information - headers already sent by (output started at /var/www/trunk/system/application/libraries/Gkml.php:305)


This line 305 is the one I mentioned before:
Code:
function genera_mobile($idterminal)
  {
...
      print $this->download_kml($this->file,‘mobile_terminal_’.$retornado[0][‘name’]);
  }

And this is the download_kml funcion.

Code:
function download_kml($file,$name = ‘googleearth’)
  {
      $fsize = mb_strlen($file);
      header(“Pragma: public”);
      header(“Expires: 0”);
      header(“Cache-Control: must-revalidate, post-check=0, pre-check=0”);
      header(“Cache-Control: public”);
      header(“Content-Description: File Transfer”);
      header(“Content-Type: application/vnd.google-earth.kml+xml”);
      header(“Content-Disposition: attachment; filename=$name.kml”);
      header(“Content-Transfer-Encoding: quoted-printable”);
      header(“Content-Length: ” . $fsize);
      return $this->file;
  }
I can’t figure out why ...

Thank you very much for your time !
#4

[eluser]InsiteFX[/eluser]
Try this, your missing the anchor tags!
Code:
<a href="http://portal.localhost/downloads/kml_mobile/6773/2949cda11484a8c93c16f41d8f3810ea"></a>

InsiteFX
#5

[eluser]J. Manuel[/eluser]
Thank you for your feedback, finally I rewrite the process in a different way and it is working from this morning.

I am working with an inherit code, and it is not really well code style, indentation, var names, ... so it makes very difficult sometimes to get the Eureka!

Thank you for your time.

Cheers,




Theme © iAndrew 2016 - Forum software by © MyBB