PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 9th, 1999, 07:00 PM
ebaum11
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
I'm trying to upload binary data and store it in mySQL as a mediumblob. Since there's always the possibility of quotes (along with any other character) within the binary stream, I assume I need to do something along the lines of AddSlashes to ensure that the sql request won't fail. The trouble is I'm finding that StripSlashes is blowing away the string when I retrieve it. I've tried rolling my own encoding, but ereg_replace("'", "'", $string) is truncating my data, apparantly at the first null character it hits.

So: what's a solution for safely getting binary data into mysql via php? (And back out again!)

Thanks.

Eric

Reply With Quote
  #2  
Old July 27th, 1999, 02:56 PM
moderator
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
I don't know if it's an option, but I'd consider a work-around.

First store the binary data in a file, then create a varchar field in the database that can store the path to that file.

Reply With Quote
  #3  
Old July 27th, 1999, 09:48 PM
chyrag
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Yeah, the method which the moderator suggests also is less demanding on mysql. It seems BLOB storing/retrieval especially if they are huge in size, are quite CPU consuming. filenames on the other hand is quite cool.

Reply With Quote
  #4  
Old July 27th, 1999, 09:50 PM
chyrag
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Yeah, the method which the moderator suggests also is less demanding on mysql. It seems BLOB storing/retrieval especially if they are huge in size, are quite CPU consuming. filenames on the other hand, with blobs in the files is quite cool; you may have to use the tempnam function to get the unique filenames.

Reply With Quote
  #5  
Old February 6th, 2000, 08:34 PM
F.Schaper F.Schaper is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2000
Location: Bremen
Posts: 11 F.Schaper User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to F.Schaper
I have spoken with Eric about this problem couse I have had the same a time ago. His sollution was simply to encode the binary string to base64 and to decode it later if needed. This works fine even if I don't know about the load this might cause. But if the image has to be in the DB this is a working way after all. Cya

Reply With Quote
  #6  
Old February 7th, 2000, 11:24 AM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 17
Send a message via AIM to rod k
There is a common misconception that you need to stripslashes() when pulling a field from mysql that had addslashes() used when stored. THIS IS NOT THE CASE. addslashes() is used to escape characters. IOW, the string:

I said, "NO!". would be changed to:
I said, "NO!". so that when it is added to mysql the quotes don't get interpreted as a control character of the query. MySQL does not store the . So when it is pulled the original string is there sans the backslashes.

The existence of stripslashes() is for other purposes, such as removing slashes added to strings passed via GPC when magic_quotes is on.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > php, mySQL, and binary data

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap