Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old June 7th, 2006, 04:25 PM
webmechanic
Guest
 
Posts: n/a
Default PHP retrieve image from Mysql database

I was able to insert images into mysql stored as binary data. How do I
retrieve it. Please provide thorough explanation. Thanks.

  #2  
Old June 7th, 2006, 11:35 PM
Norman Peelman
Guest
 
Posts: n/a
Default Re: PHP retrieve image from Mysql database

"webmechanic" <dmitrymar@yahoo.com> wrote in message
news:1149693940.744768.258410@g10g2000cwb.googlegr oups.com...[color=blue]
> I was able to insert images into mysql stored as binary data. How do I
> retrieve it. Please provide thorough explanation. Thanks.
>[/color]

Do your SELECT:

$query = "SELECT blobfield FROM table WHERE ????";

$result = mysql_query($query, $dbc);
$result_data = mysql_fetch_array($result, MYSQL_ASSOC);
$img = imagecreatefromstring($result_data['blobfield']);

---

Just lookup the exact function parameters as that is just off the top off my
head...

Norm
--
FREE Avatar hosting at www.easyavatar.com


  #3  
Old June 8th, 2006, 08:05 AM
lorento
Guest
 
Posts: n/a
Default Re: PHP retrieve image from Mysql database

"webmechanic" wrote :[color=blue]
> I was able to insert images into mysql stored as binary data.[/color]

because its a binary data you can just echo the content data. Try like
this :

<?php
$query = "SELECT blobfield FROM table WHERE ????";
$result = mysql_query($query, $dbc);
$result_data = mysql_fetch_array($result, MYSQL_ASSOC);


header("Content-type: image/jpeg") ;
echo $result_data['blobfield'];

?>

regards,

Lorento
--
http://blogs.deshot.com
http://www.mastervb.net
http://www.immersivelounge.com

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,248 network members.