Jump to content

MySQL BLOB Data Type


nafees

Recommended Posts

hello there,

 

i'm facing problems retrieving BLOB values in a text area box. Can anyone tell me how to retrieve the values of the blob field. also plz tell me how to get the original data from the encrypted binary BLOB data.

 

Regards,

 

Nafees

Link to comment
Share on other sites

Depends what kind of data is in there....  BLOB is just binary.

 

 

Luckily, with PHP, handling BLOB stuff isn't too hard.  It's actually just about like a normal column.

 

 

$q = mysql_query("SELECT some_blob_column FROM some_table LIMIT 1");

$r = mysql_fetch_row($q);

echo $r[0];

 

 

for example.

Link to comment
Share on other sites

hello there,

 

thanks a lot for ur reply. i was looking to add a Microsoft Word formated document into the BLOB data field. My objective is to retrieve tht formated data from the BLOB field using php. can u tell me how to do tht. I can retrieve plain text data but failed to retrieve the formated one.

 

Regards,

 

Nafees

Link to comment
Share on other sites

<?php
//pretend $q is a query resource
if($q && mysql_num_rows($q)) {
    $r = mysql_fetch_assoc($q);
    header("Content-Type: application/msword"); //not sure if application/msword is actually the word document MIME type
    //I doubt it is, but I don't feel like Googling.
    echo $r['blob_column_name'];
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.