• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
cannot modify headers bug?

#1
[eluser]superfake123[/eluser]
Hello, I keep getting the following error / warning

Code:
ERROR - 2012-06-24 20:16:07 --> Severity: Warning  --> Cannot modify header information - headers already sent by (output started at /home/user/public_html/html_project/system/application/models/admin_model.php:173) /home/user/public_html/html_project/system/core/Output.php 92


line 173 of admin_model is:

Code:
imagejpeg($image,"",80);


Should I not be using that?



Thanks..

#2
[eluser]PhilTem[/eluser]
It looks like you create an error with the second argument you provide for imagejpg. I think what you need to know (from the PHP Doc)

Quote:Parameters:
filename:
The path to save the file to. If not set or NULL, the raw image stream will be outputted directly.

To skip this argument in order to provide the quality parameter, use NULL.

Try setting the second parameter to NULL and see what happens^^

#3
[eluser]superfake123[/eluser]
nope, it still does it D:

This started after I added to the admin controller construct:

Code:
$this->output->set_header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");
$this->output->set_header("Cache-Control: post-check=0, pre-check=0", false);
$this->output->set_header("Pragma: no-cache");

I was having issues in IE not reloading any changes made in the admin panel so I needed to add the above. I'm not sure how to fix this :\

#4
[eluser]superfake123[/eluser]
still happening D:

here is the entire function that is causing the warning

Code:
public function slideshow_thumb($img, $maxDim, $location)
{
  $location = str_replace('-', '/', $location);
  list($curImgW, $curImgH) = getimagesize('images/'.$location.'/'.$img);

  if($curImgH > $curImgW)
  {
   $dif = $maxDim/$curImgH;
   $newH = $maxDim;
   $newW = floor($curImgW*$dif);
  }
  else
  {
   $dif = $maxDim/$curImgW;
   $newW = $maxDim;
   $newH = floor($curImgH*$dif);
  }

  ini_set('memory_limit','128M');
  $startImg = imagecreatefromjpeg('images/'.$location.'/'.$img);
  $image = imagecreatetruecolor($newW, $newH);

  imagecopyresampled($image, $startImg, 0, 0, 0, 0, $newW, $newH, $curImgW, $curImgH);
  imagejpeg($image, NULL, 80);
  imagedestroy($startImg);
  imagedestroy($image);

}

#5
[eluser]superfake123[/eluser]
sorry, bump! anyone?

#6
[eluser]CroNiX[/eluser]
The problem could probably be that you are outputting the image (via imagejpeg) before the headers are sent along with the rest of the final output from the controller. Try returning your image and outputting it from your controller with the rest of your data so it gets buffered with the rest of the content.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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