thecard Posted December 6, 2008 Share Posted December 6, 2008 <img src="counter.php" height="50" width="450" border='0' /> The .php file echos an image with a variable echoed on top of the image. But all that appears on the page is the firefox sign meaning broken link or something... But when I right click the empty image and click "view image" I see the image in a new window how it should be so it isn't a broken link. I know this can be done. Where am I going wrong ???? Thanks for any help. thecard Quote Link to comment https://forums.phpfreaks.com/topic/135848-solved-forcing-php-through-img-tag/ Share on other sites More sharing options...
gevans Posted December 7, 2008 Share Posted December 7, 2008 can you post counter.php? Quote Link to comment https://forums.phpfreaks.com/topic/135848-solved-forcing-php-through-img-tag/#findComment-708138 Share on other sites More sharing options...
thecard Posted December 7, 2008 Author Share Posted December 7, 2008 echo'<img src="images/hitcounter2.png" /> '; For now that is all it is. In the future it will echo the var on top of it. Quote Link to comment https://forums.phpfreaks.com/topic/135848-solved-forcing-php-through-img-tag/#findComment-708142 Share on other sites More sharing options...
gevans Posted December 7, 2008 Share Posted December 7, 2008 <?php header("Content-type: image/png"); return "images/hitcounter2.png"; ?> Try using that in place of the current echo statement Quote Link to comment https://forums.phpfreaks.com/topic/135848-solved-forcing-php-through-img-tag/#findComment-708147 Share on other sites More sharing options...
thecard Posted December 7, 2008 Author Share Posted December 7, 2008 That didn't work. Still the symbol of a broken link. But now when I click "view image" all that shows in the new window is text saying the url /counter.php. . Thanks for the thought though. Quote Link to comment https://forums.phpfreaks.com/topic/135848-solved-forcing-php-through-img-tag/#findComment-708150 Share on other sites More sharing options...
gevans Posted December 7, 2008 Share Posted December 7, 2008 <?php header("Content-type: image/png"); echo "images/hitcounter2.png"; ?> That works on my machine Quote Link to comment https://forums.phpfreaks.com/topic/135848-solved-forcing-php-through-img-tag/#findComment-708153 Share on other sites More sharing options...
thecard Posted December 7, 2008 Author Share Posted December 7, 2008 Using that code mine comes up with: 'The image “counter.php” cannot be displayed, because it contains errors.' agh. Why? It's not the image I'm using, I've tried others...and this one is fine anyway! This is annoying. Quote Link to comment https://forums.phpfreaks.com/topic/135848-solved-forcing-php-through-img-tag/#findComment-708159 Share on other sites More sharing options...
gevans Posted December 7, 2008 Share Posted December 7, 2008 <?php echo "images/hitcounter2.png"; ?> try it with just the src Quote Link to comment https://forums.phpfreaks.com/topic/135848-solved-forcing-php-through-img-tag/#findComment-708161 Share on other sites More sharing options...
thecard Posted December 7, 2008 Author Share Posted December 7, 2008 Then it just echos the string: images/hitcounter2.png . Quote Link to comment https://forums.phpfreaks.com/topic/135848-solved-forcing-php-through-img-tag/#findComment-708163 Share on other sites More sharing options...
gevans Posted December 7, 2008 Share Posted December 7, 2008 <img src="counter.php" height="50" width="450" border='0' /> with the image tag it shouldn't echo the code, it should just show the image Quote Link to comment https://forums.phpfreaks.com/topic/135848-solved-forcing-php-through-img-tag/#findComment-708164 Share on other sites More sharing options...
thecard Posted December 7, 2008 Author Share Posted December 7, 2008 But it doesn't Quote Link to comment https://forums.phpfreaks.com/topic/135848-solved-forcing-php-through-img-tag/#findComment-708167 Share on other sites More sharing options...
PFMaBiSmAd Posted December 7, 2008 Share Posted December 7, 2008 After the image header is output, you need to read and output the contents of the image file. readfile() is the simplest way - http://us3.php.net/readfile Quote Link to comment https://forums.phpfreaks.com/topic/135848-solved-forcing-php-through-img-tag/#findComment-708169 Share on other sites More sharing options...
thecard Posted December 7, 2008 Author Share Posted December 7, 2008 Thats AWESOME. Only problem is, how am I going to write a string onto (as in over) that image now from the counter.php file? Quote Link to comment https://forums.phpfreaks.com/topic/135848-solved-forcing-php-through-img-tag/#findComment-708170 Share on other sites More sharing options...
MadTechie Posted December 7, 2008 Share Posted December 7, 2008 Heres a basic example that may help <img src="counter.php?c=10" height="50" width="450" border='0' /> <?php header("Content-type: image/png"); $Count = (int)$_GET['c']; $im = imagecreatefrompng("images/hitcounter2.png"); $tc = imagecolorallocate($im, 0, 0, 0); imagestring($im, 1, 5, 5, $Count, $tc); imagepng($im); imagedestroy($im); exit(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/135848-solved-forcing-php-through-img-tag/#findComment-708175 Share on other sites More sharing options...
thecard Posted December 7, 2008 Author Share Posted December 7, 2008 Thanks sooo much to everyone in this thread! Your very helpful, good people. When I'm good enough to help people on the forums as you are, I will lots and lots to repay my dept to this great community. Quote Link to comment https://forums.phpfreaks.com/topic/135848-solved-forcing-php-through-img-tag/#findComment-708407 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.