Jump to content

[SOLVED] PHP and BLOB


miket3

Recommended Posts

ok...  I decided to store my images in a DB.  I have most of it working except I cant copy BLOB from one record to another record...  Has anybody done this?

 

I can read binary file contents into a variable and then store it in the database without issue.  What is so different about grabbing BLOB data from a field into a variable and back into a BLOB field?  Heck it will even display fine after being grabbed from the BLOB.  BUt what is missing when trying to do this:

BLOB -> $image -> BLOB

 

I can do:

FILE.PNG -> $image -> BLOB

and

BLOB -> $image -> SCREEN

but not:

BLOB -> $image -> BLOB

 

 

here is some code:

 

$couponid = $_REQUEST["couponid"];

$memberid = $_REQUEST["memberid"];

$result = mysql_query("SELECT image FROM ".COUPONTABLE." WHERE memberid = '".$memberid."' AND couponid = '".$couponid."'");

 

$row = mysql_fetch_assoc($result);

$image = $row[image];

$result = mysql_query("UPDATE ".COUPONTABLE." SET image=".$row[image]." WHERE memberid = '11' AND couponid = 'buddy4-4'");

header("Content-type: image/png");

print $image;

 

Thanks,

 

There is a little trick to this or a bug?

Link to comment
https://forums.phpfreaks.com/topic/171068-solved-php-and-blob/
Share on other sites

Hey... I have an idea....  How about next time I make sure that the source record actually has data in the BLOB field before trying to copy it to other records. :wtf:::)

 

it was a combo... I also learned that you ALWAYS need to use ADDSLASHES() to assign binary data to a variable.

Link to comment
https://forums.phpfreaks.com/topic/171068-solved-php-and-blob/#findComment-902226
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.