Jump to content

Archived

This topic is now archived and is closed to further replies.

technode

Cannot Modify Header Information

Recommended Posts

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.

[code]
<html>
<head></head>
<body><?php

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);
imagepng($im);
imagedestroy($im);

?></body></html>[/code]

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
[/quote]

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

Share this post


Link to post
Share on other sites
Put the header (blah blah blah ) first. You can't have that HTML before it.

Share this post


Link to post
Share on other sites
[!--quoteo(post=389408:date=Jun 29 2006, 02:38 PM:name=technode)--][div class=\'quotetop\']QUOTE(technode @ Jun 29 2006, 02:38 PM) [snapback]389408[/snapback][/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.
[/quote]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.