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
https://forums.phpfreaks.com/topic/132056-solved-header-errors/
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
https://forums.phpfreaks.com/topic/132056-solved-header-errors/#findComment-686209
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
https://forums.phpfreaks.com/topic/132056-solved-header-errors/#findComment-686211
Share on other sites

Archived

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

×
×
  • 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.