This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Dreamweaver > March 2005 > Display images from PHP and MySQL





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Display images from PHP and MySQL
Affen

2005-03-28, 6:35 pm

Hi
I am struggelig to display images stored in a mysql database through PHP and
Dreamweaver. The images are uploaded by using the mysql Query Browser and
displays fine here. In Dreamweaver MX I have created a database connection to
MySQL, and created a recordset in the bindings panel. By draging fields from
the bindings panel I get all fields to display their content except the image
field which is of type MEDIUMBLOB - this field displays as a jumble of text and
is of course the binary representation of the picture. Question is - how do i
get Dreamweaver to display the image as a jpg and not as binary data?
This is the only code inserted by dragging the fields from bindings panel:

<?php echo $row_ShowPic['PicNum']; ?>
</p>
<p><?php
echo $row_ShowPic['Image'];
?>

Greatful for some tips here.


Joe Makowiec

2005-03-28, 6:35 pm

On 23 Mar 2005 in macromedia.dreamweaver, Affen wrote:

> I am struggelig to display images stored in a mysql database
> through PHP and
> Dreamweaver. The images are uploaded by using the mysql Query
> Browser and displays fine here. In Dreamweaver MX I have created a
> database connection to MySQL, and created a recordset in the
> bindings panel. By draging fields from the bindings panel I get
> all fields to display their content except the image field which is
> of type MEDIUMBLOB - this field displays as a jumble of text and is
> of course the binary representation of the picture. Question is -
> how do i get Dreamweaver to display the image as a jpg and not as
> binary data?
> This is the only code inserted by dragging the fields from bindings
> panel:
>
> <?php echo $row_ShowPic['PicNum']; ?>
> </p>
> <p><?php
> echo $row_ShowPic['Image'];
> ?>


It would be a whole lot easier if you were to store the filename in the
database, and use that to display an already-uploaded image. If it's a
security issue, what you'd have to do is create a separate PHP script
to display the image, thus:

<?php do { ?>
<p><img src="showpicture.php?id=<?php echo $pictureid ?>"></p>
<?php } while (whatever) ?>

where showpicture.php is a script to display the contents of the blob
field; see
http://us4.php.net/manual/en/function.imagejpeg.php
http://us2.php.net/imagecreatefromstring
for more information.

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php
Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews