473,396 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Read blob from mysql

Hello,

I do have a mysql database with a BLOB column. What is the proprest way
to read this column ?

Thx,
Thierry

Jul 17 '05 #1
3 21887
Thierry <thierry_at_iceprod.com@no_spam_please.com> writes:
I do have a mysql database with a BLOB column. What is the proprest way
to read this column ?


SELECT it just like any other field. Some people mistakenly say
to use stripslashes() on the result, but it's almost always wrong
to do so.

Are you having trouble working with binary data? If so then please
elaborate.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
Jul 17 '05 #2
Michael Fuhr wrote:
Thierry <thierry_at_iceprod.com@no_spam_please.com> writes:

I do have a mysql database with a BLOB column. What is the proprest way
to read this column ?

SELECT it just like any other field. Some people mistakenly say
to use stripslashes() on the result, but it's almost always wrong
to do so.

Are you having trouble working with binary data? If so then please
elaborate.


Question for Michael (since I am not the original poster): Why would
performing a stripslashes() on the result be *almost* always wrong on a
BLOB column? I could see where this might be suggested for binary data,
but not for ascii text... I'm just curious since I store data in BLOBs
(and read them back using SELECT) and I'm wondering if there is
something that I am (or am not considering) that I may not know about...

thanks
randelld
Jul 17 '05 #3
"Randell D." <pl*******************@news.group.com> writes:
Michael Fuhr wrote:
Thierry <thierry_at_iceprod.com@no_spam_please.com> writes:
I do have a mysql database with a BLOB column. What is the proprest way
to read this column ?


SELECT it just like any other field. Some people mistakenly say
to use stripslashes() on the result, but it's almost always wrong
to do so.

Are you having trouble working with binary data? If so then please
elaborate.


Question for Michael (since I am not the original poster): Why would
performing a stripslashes() on the result be *almost* always wrong on a
BLOB column? I could see where this might be suggested for binary data,
but not for ascii text... I'm just curious since I store data in BLOBs
(and read them back using SELECT) and I'm wondering if there is
something that I am (or am not considering) that I may not know about...


I said "almost always wrong" because I could contrive a situation
where calling stripslashes() on retrieved data would be appropriate.
For example, if magic_quotes_gpc is turn on but a script doesn't
check it with get_magic_quotes_gpc() and calls addslashes() or
mysql_escape_string() on form data anyway, then the form data would
be double-escaped. If the double-escaped data is inserted into a
database, then you'd need to call stripslashes() after retrieving
the data to get it back to its original format. Proper coding would
have avoided this, but if you're working on a project with other
programmers then you may not have control over how data is inserted
into the database.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Sugapablo | last post by:
Is there any PHP function that will allow me to determine the MIME type of a blob stored in MySQL? Specifically, if I'm storing an image as a blob in MySQL, is there any PHP function that can...
0
by: Mark Fisher | last post by:
I cannot seem to store binary data as a BLOB. I used the following to create a table capable of holding a BLOB: CREATE TABLE blob_table ( id INT UNSIGNED NOT NULL AUTO_INCREMENT,...
7
by: sime | last post by:
Hi, I have a blob field in a mysql database table. I want to copy a blob from one record to another. I am having trouble transferring the data via a php variable. Maybe I need to addslashes or...
3
by: hamvil79 | last post by:
I'm implementig a java web application using MySQL as database. The main function of the application is basically to redistribuite documents. Those documents (PDF, DOC with an average size around...
1
by: yoes | last post by:
Dear all, I am very new in MySQL, I am working on image database project for my research and I have problem how to convert blob field into float in MySQL so that I can calculate the blob field...
0
by: dimitri pater | last post by:
Hi, I am trying to insert an image, which is stored as a blob in MySQL, into a table using Reportlab. I have tried this: from StringIO import StringIO cfoto = StringIO(result) # where result...
2
by: jith87 | last post by:
I m using JSP @ front end and MySql db @ back end and the connectivity thru JDBC. While retrieving a blob(MySql format) from the db back to JSP i need to convert ths to blob(Java comaptible format).....
4
by: =?ISO-8859-1?Q?Hans_M=FCller?= | last post by:
Good morning folks, I cannot read a binary file into a mysql database. Everything I tried did not succeed. What I tried (found from various google lookups...) is this: con =...
4
by: skunapareddy | last post by:
I am needing to read a blob from database and pass it to another java program. I researched internet and found a program that reads a file on the client pc and gives bytes, but when I modified the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.