473,804 Members | 3,049 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 21924
Thierry <thierry_at_ice prod.com@no_spa m_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_ice prod.com@no_spa m_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.gr oup.com> writes:
Michael Fuhr wrote:
Thierry <thierry_at_ice prod.com@no_spa m_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_gp c is turn on but a script doesn't
check it with get_magic_quote s_gpc() and calls addslashes() or
mysql_escape_st ring() 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
7440
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 determine whether it's a gif, jpeg, png, etc? -- http://www.sugapablo.com <--music ] http://www.sugapablo.net <--personal ]
0
2328
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, binary_stuff BLOB, PRIMARY KEY (id) );
7
11486
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 convert to Hex or something. I've tried a few things but can't quite get it. Here is simplified code. mysql_select_db($dbname, $connection);
3
4728
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 2Mb) are stored in BLOB column. The amount of documents for the first year should not exceed 5/6 Giga, but I cannot make prevision for the next years. Those documents are mainly just accessed (update and delete are not so
1
4818
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 with the MATH operation. Does any one how to do it ???? Thank you very much indeed , for your help.
0
2140
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 is the 'blob' cfoto.seek(0) foto=cfoto.getvalue
2
7713
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).. For ths i ve used getBlob() specified in the ResultSet API docs. Bt when i run i get an error as com.mysql.jdbc.Blob@152c4d9 The above gets printed for all the blobs with a diff in the no present @ the end.... How do u convert these...
4
7245
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 = MySQLdb.connect(to server) cur = con.cursor() cur.execute("insert into data values('file1', %s)", (open("test.jpg", "rb").read(), ))
4
4266
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 code to read a blob from DB I am not having any luck, I am running this java programs using JDEVELOPER. Can anyone please give me some help? The code is as follows: ... private static byte getBytesFromBlob(Blob blob) throws Exception { ...
0
9704
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9572
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10562
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10319
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10303
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9132
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7608
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5508
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5639
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.