technode Posted June 29, 2006 Share Posted June 29, 2006 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><?phpheader("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.4Please help me!!!!Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/13240-cannot-modify-header-information/ Share on other sites More sharing options...
Buyocat Posted June 29, 2006 Share Posted June 29, 2006 Put the header (blah blah blah ) first. You can't have that HTML before it. Quote Link to comment https://forums.phpfreaks.com/topic/13240-cannot-modify-header-information/#findComment-50973 Share on other sites More sharing options...
effigy Posted June 29, 2006 Share Posted June 29, 2006 [!--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] Quote Link to comment https://forums.phpfreaks.com/topic/13240-cannot-modify-header-information/#findComment-50979 Share on other sites More sharing options...
wildteen88 Posted June 29, 2006 Share Posted June 29, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/13240-cannot-modify-header-information/#findComment-50982 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.