deathraylabs Posted January 19, 2007 Share Posted January 19, 2007 I can create an image or I can create a html page but can't seem to get them both to work on the same page. Could someone post a snippit of an example of this working? I assume it has to do with headers? Link to comment https://forums.phpfreaks.com/topic/34902-php-image-and-html-wont-print-on-same-page/ Share on other sites More sharing options...
kenrbnsn Posted January 19, 2007 Share Posted January 19, 2007 Please post the code you have that doesn't work.Ken Link to comment https://forums.phpfreaks.com/topic/34902-php-image-and-html-wont-print-on-same-page/#findComment-164566 Share on other sites More sharing options...
deathraylabs Posted January 19, 2007 Author Share Posted January 19, 2007 O.K., it is a graph that someone else created. Hope this helps. Any example would work as long as it put an image and html on the same page. Have been trying to figure this out for days. - Thanks[code]<? function createGraph($graphValues) { global $image; $imgWidth=250; $imgHeight=250; // Create image and define colors $image=imagecreate($imgWidth, $imgHeight); $colorWhite=imagecolorallocate($image, 255, 255, 55); $colorGrey=imagecolorallocate($image, 192, 192, 192); $colorBlue=imagecolorallocate($image, 0, 0, 255); $colorLightBlue=imagecolorallocate($image, 167, 211, 237); $colorDarkBlue=imagecolorallocate($image, 5, 107, 165); // Create border around image imageline($image, 0, 0, 0, 250, $colorGrey); imageline($image, 0, 0, 250, 0, $colorGrey); imageline($image, 249, 0, 249, 249, $colorGrey); imageline($image, 0, 249, 249, 249, $colorGrey); // Create grid for ($i=1; $i<11; $i++){ imageline($image, $i*25, 0, $i*25, 250, $colorGrey); imageline($image, 0, $i*25, 250, $i*25, $colorGrey); } // Create bar charts for ($i=0; $i<10; $i++){ imagefilledrectangle($image, $i*25, (250-$graphValues[$i]), ($i+1)*25, 250, $colorDarkBlue); imagefilledrectangle($image, ($i*25)+1, (250-$graphValues[$i])+1, (($i+1)*25)-5, 248, $colorLightBlue); } return($image); }// echo 'if this line is included after the image, my image shows but not this text. If I place this text before the image/header info, I don\'t get either.'; $graphValues=array(20,80,23,11,200,245,50,80,111,15,55); createGraph($graphValues); header('Content-type: image/png'); header('Content-Length: ' . strlen($image)); echo '<img src="' . imagePNG($image) . '" width="250" height="250">';// echo 'if this line is included after the image, my image shows but not this. If I place this before the image/header info, I don\'t get either.';?>[/code] Link to comment https://forums.phpfreaks.com/topic/34902-php-image-and-html-wont-print-on-same-page/#findComment-164586 Share on other sites More sharing options...
.josh Posted January 19, 2007 Share Posted January 19, 2007 it's because you are sending headers and then trying to display html. divide the 2 into 2 different scripts and have your html script call the image like normal, but with the image script as the source:[code]<img src='image.php' />[/code]if you are having trouble with seperating the 2, look into captcha tutorials; it's essentially the same thing. Link to comment https://forums.phpfreaks.com/topic/34902-php-image-and-html-wont-print-on-same-page/#findComment-164590 Share on other sites More sharing options...
deathraylabs Posted January 19, 2007 Author Share Posted January 19, 2007 Hey that worked. Thanks a bunch! Link to comment https://forums.phpfreaks.com/topic/34902-php-image-and-html-wont-print-on-same-page/#findComment-164643 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.