Jump to content


Cannot Modify Header Information

  • Please log in to reply
3 replies to this topic

#1 technode

  • Members
  • Pip
  • Newbie
  • 6 posts

Posted 29 June 2006 - 07:38 PM

Ok, so I have tried everything I can think of and wandered the web too.. nothing seems to work.

I am trying to create an image with PHP. Which should work, but doesn't.


header("Content-type: image/png");
$string = "image";
$im    = imagecreatefrompng("button1.png");
$orange = imagecolorallocate($im, 220, 210, 60);
$px    = (imagesx($im) - 7.5 * strlen($string)) / 2;
imagestring($im, 3, $px, 9, $string, $orange);


the error is:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\createImg\createImg.php:3) in C:\Program Files\Apache Group\Apache2\htdocs\createImg\createImg.php on line 5

I have tried removing extra returns and white space in the code, in the ini files.... It's an Apapche 2 server with php 5.1.4

Please help me!!!!

Thanks in advance

#2 Buyocat

  • Members
  • PipPipPip
  • Advanced Member
  • 267 posts

Posted 29 June 2006 - 07:40 PM

Put the header (blah blah blah ) first. You can't have that HTML before it.
Looking for some easy-to-use tools?  Try these, https://sourceforge....jects/utils-php -- I made them myself.  They're distinct tools which are easy to understand and use.  See some examples uses at http://www.anotherearlymorning.com

#3 effigy

  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 29 June 2006 - 07:54 PM

[!--quoteo(post=389408:date=Jun 29 2006, 02:38 PM:name=technode)--][div class=\'quotetop\']QUOTE(technode @ Jun 29 2006, 02:38 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Ok, so I have tried everything I can think of...[/quote]

...except reading the manual:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP.
Regexp | Unicode Article | Letter Database

#4 wildteen88

  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 29 June 2006 - 08:06 PM

Also if you are creating an image it is pointless having any HTML in the file that is creating the image. As you cannot create an image and use html or any other text at the same time. So remove all html.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users