[thelist] Image in PHP

Jack Timmons jorachim at gmail.com
Thu Apr 16 07:52:51 CDT 2009


On Thu, Apr 16, 2009 at 7:01 AM, HP Thniah <heanpeng at gmail.com> wrote:
> I developed a PHP script to output the results of a survey in the form of a
> GIF image.
>
> The issue is that I would like to include titles and links on the page but
> they dont work. Please advise.
>
> The script below produces the GIF image but ignores the echo bit. Any titles
> I add (by using the echo function also doesn't work).
>
> <?php
> Header("Content-Type: image/gif");
> ....
> $im = ImageCreate($xDim, $yDim);
> $backg = ImageColorAllocate($im, 255,255,200);
> $blue = ImageColorAllocate($im, 0, 0, 255);
> $nY = 0;
> ...
> ImagePNG($im);
> mysql_close($con);
> echo "<br>Back To [<a href=\"test.html\">Main</a>]<br>";
> ?>

That would be due to you outputting in a header that the content is a
gif. Since that is what the browser is expecting, that's all it
assembles and shows.

If you wish to have the image and link on a page, you need to set an
image tag with the URL of the generated image as the source (IE:
image.php?action=result).

Best thing I can think of before coffee. I swear, I need more and more
sleep each day to function at a level someone drunk might mistake as
properly.

-- 
-Jack Timmons
http://www.trotlc.com
Twitter: @codeacula



More information about the thelist mailing list