Connecting Tech Pros Worldwide Help | Site Map

Read blob from mysql

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 01:10 AM
Thierry
Guest
 
Posts: n/a
Default 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


  #2  
Old July 17th, 2005, 01:10 AM
Michael Fuhr
Guest
 
Posts: n/a
Default 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, 01:11 AM
Randell D.
Guest
 
Posts: n/a
Default 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, 01:11 AM
Michael Fuhr
Guest
 
Posts: n/a
Default 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/
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.