Image appears as binary in browser

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
okee
Forum Newbie
Posts: 5
Joined: Thu Jan 16, 2003 4:48 pm

Image appears as binary in browser

Post by okee »

I have a feeling theres a really simple answer to this but I'm fairly new to php, been using it for 2 days.
when I do the following it works

<?php
$im = imagecreatefrompng ("house.png");
imagepng($im);
?>

But when I try to display the pictures in a table like so

while ($Row = mysql_fetch_array($Result))
{

print ("<td height=441 width=664 align=center valign=middle>
<table width=600 border=1 cellpadding=4 cellspacing=0 align=center>
<tr>
<td height=12 bgcolor=#009900 width=198><b><font color = #FFFFFF face=Verdana, Arial, Helvetica, sans-serif size=2>$Row[Category]</font></b></td>
<td height=12 bgcolor=#009900 width=396><font color = #FFFFFF face=Verdana, Arial, Helvetica, sans-serif size=2>$Row[DateAdded]</font></td>
</tr>
<tr><td halign=center
");
$im = imagecreatefrompng ("house.png");
imagepng($im);

print("</td>
<td height=120 width=396 valign=top><font face=Verdana, Arial, Helvetica, sans-serif size=2>$Row[Description]</font></td>
</tr>
<tr>
<td valign=top height=16 colspan=2><font face=Verdana, Arial, Helvetica, sans-serif size=2></font></td>
</tr>
</table></td>
");
}

mysql_close($Link);

?>


any ideas.
Also i just wanted to know would it be much of a speed overhead to display pictures as thumbnails using php rather than having premade thumbnails.

thanks

okee
fractalvibes
Forum Contributor
Posts: 335
Joined: Thu Sep 26, 2002 6:14 pm
Location: Waco, Texas

Post by fractalvibes »

Probably best would be a separate PHP script just for showing images, as
you have add a header with the content type (image/gif,image/jpeg, etc.)
for this to work.

You really can't mix content types in the overall page. But you could do:
<tr>
<td><img src='MyImageViewer.php?ID=56565'>
</td>
</tr>


Phil Jackson
Post Reply