Jump to content

[SOLVED] Header Errors


Recreational_Champ

Recommended Posts

<?php
header ("Content-type: image/png");

$cavas = imagecreate(300,300);
$gray = imagecolorallocate ($cavas,0xcc,0xcc,0xcc);
$white = imagecolorallocate ($cavas,0x33,0x33,0x33);
$light_purple = imagecolorallocate ($cavas,943,387,453);
$color = imagecolorallocate ($cavas,'abc',123,956);

imagefilledrectangle($cavas,0,0,40,70,$white);
imagefilledrectangle($cavas,0,80,20,160,$light_purple);
imagefilledrectangle($cavas,0,170,70,250,$color);

imagepng($cavas);
?>

 

 

How can I add that image that I created to an existing page without header errors?

Link to comment
Share on other sites

Well, thats all that I have on that page --which works well alone. 

 

It will be a graph based on poll results and I want to display other other php/html code next to that image.

 

<?php
header ("Content-type: image/png");
      
$cavas = imagecreate(300,300);
$gray = imagecolorallocate ($cavas,0xcc,0xcc,0xcc);
$white = imagecolorallocate ($cavas,0x33,0x33,0x33);
$light_purple = imagecolorallocate ($cavas,943,387,453);
$color = imagecolorallocate ($cavas,'abc',123,956);

imagefilledrectangle($cavas,0,0,40,70,$white);
imagefilledrectangle($cavas,0,80,20,160,$light_purple);
imagefilledrectangle($cavas,0,170,70,250,$color);
   
imagepng($cavas);
?>
<html>
<h2>Poll results:</h2>
</html>

 

 

make sense?

Link to comment
Share on other sites

That's not the way to do it. You should just use html <img> tags to place these pictures on the page

 

<img src="yourimage.php" />

 

think of it this way: The script that creates an image is an image. For the page itself, you need another file.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.