Jump to content

Insert query containing mediumblob


christh

Recommended Posts

Hi forum members

 

I hope you can help me.

 

If I have a table that contains uploaded documents stored in a MediumBlob - can I move it/insert a MediumBlob field into another table in the same ways as I would and INT or VarChar?

 

I can download and view the documents without issue but I'd like to move certain records to another table using a Query/Insert INTO however the insert fails if I include the MediumBlob field within the query.

 

Everything is inserted if I drop the MediumBlob field which makes me suspect I need to treat this type of data in a different fashion or do I have an error else where? - I've spend 2 hours double checking my script and I can't spot a typo...

 

mysql_query ("INSERT INTO data_main  (date, name, telephone, location, status, email, fname, size, type, content ) 
VALUES
('$date','$name', '$telephone', '$location', '$stat', '$email', '$fname', '$size', '$type', '$content')");

 

content / $content is the MediumBlob field and is extracted and stored from a standard query 

 

$content=$row['content'];

 

I've used an echo statement to confirm that the data is stored in $content however it just won't insert - With it removed from the insert query the insert.

 

Hopefully my problem is easy enough to follow and thanks in advance.

 

Chris

Link to comment
Share on other sites

Hi and thanks for getting back to me.

 

More than happy to post anything you feel would be helpful - what do you mean by data?  The actual contents of the table or the query that extracts the data from the table.

 

The mediumblob ($content) is an uploaded Word doc.

 

Sorry for being dim.

 

Chris

Link to comment
Share on other sites

Hi again

 

Thanks for pointing me in the right direction and you were spot on - after reading up, if you want to insert binary data into a BLOB column it needs to be escaped.

 

I added the following to my initial query

 

$content=$row['content'];

$content = addslashes($content);

 

The insert query then worked.

 

Again thanks for your help.

 

Chris

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.