Connecting Tech Pros Worldwide Help | Site Map

Read blob from mysql

  #1  
Old July 17th, 2005, 02:10 AM
Thierry
Guest
 
Posts: n/a
Hello,

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

Thx,
Thierry

  #2  
Old July 17th, 2005, 02:10 AM
Michael Fuhr
Guest
 
Posts: n/a

re: Read blob from mysql


Thierry <thierry_at_iceprod.com@no_spam_please.com> writes:
[color=blue]
> I do have a mysql database with a BLOB column. What is the proprest way
> to read this column ?[/color]

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/
  #3  
Old July 17th, 2005, 02:11 AM
Randell D.
Guest
 
Posts: n/a

re: Read blob from mysql


Michael Fuhr wrote:[color=blue]
> Thierry <thierry_at_iceprod.com@no_spam_please.com> writes:
>
>[color=green]
>>I do have a mysql database with a BLOB column. What is the proprest way
>>to read this column ?[/color]
>
>
> 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.
>[/color]

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
  #4  
Old July 17th, 2005, 02:11 AM
Michael Fuhr
Guest
 
Posts: n/a

re: Read blob from mysql


"Randell D." <please.post.and.share@news.group.com> writes:
[color=blue]
> Michael Fuhr wrote:[color=green]
> > Thierry <thierry_at_iceprod.com@no_spam_please.com> writes:
> >[color=darkred]
> >>I do have a mysql database with a BLOB column. What is the proprest way
> >>to read this column ?[/color]
> >
> > 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.[/color]
>
> 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...[/color]

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/
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
StringIO MySQL data blob Image problem dimitri pater answers 0 September 5th, 2007 08:15 PM
Extract BLOB from MySQL & save them anywhere in our pc Vinciz answers 2 February 28th, 2007 03:59 PM
PHP, mysql, and escaping characters Taras_96 answers 3 February 8th, 2007 03:35 AM
save BLOB to file from MySQL using c# Markusek Peter answers 1 November 18th, 2005 05:22 AM