Forum Moderators: coopster

Message Too Old, No Replies

Using blob

         

j05hr

6:42 pm on Oct 29, 2009 (gmt 0)

10+ Year Member



Hi,
I'm storing a blob in my database and I'm trying to get it to show on my page. I'm ok doing it with text, but when using a blob it comes up with loads of random characters. How do I fix this?

Thanks,
Josh

bkeep

9:24 pm on Nov 9, 2009 (gmt 0)

10+ Year Member



You are storing text as a blob type in MySQL?

A BLOB is a binary large object that can hold a variable amount of data.
BLOB values are treated as binary strings (byte strings). They have no character set

j05hr

9:40 pm on Nov 9, 2009 (gmt 0)

10+ Year Member



Sorry, no i mean i'm ok at getting my page to display text but when I use blob to echo back my image, it comes back in millions of letters.

bkeep

9:43 pm on Nov 9, 2009 (gmt 0)

10+ Year Member



something like this may work with some modification on your part.

$query = "SELECT filetype, bin_data FROM tbl_Files WHERE id_files='$Id';";
$result = mysql_query($query);
$query_data = mysql_fetch_array($result);
$bin_data = $query_data["bin_data"];
$filetype = $query_data["filetype"];

header("Content-type: $filetype");
echo $bin_data;