473,626 Members | 3,952 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to read blob data from database

2 New Member
i have inserted blob data in database , but i am not able to access back that data to the browser. i have php script but it does not work proprly.
our script is below
Expand|Select|Wrap|Line Numbers
  1. if ($_REQUEST[gim] == 1) {
  2.     header("Content-type: image/jpeg");
  3.     print $bytes;
  4.     exit ();
  5. }
  6.  
but it does not work correctly.
the Question is now that how i will read blob data to the browser
Thanksss
Nov 12 '07 #1
1 8375
ak1dnar
1,584 Recognized Expert Top Contributor
Only thing you need to set up the correct header.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $con = mysql_connect('localhost', 'root', 'dba') or die ("Could not connect to the Database");
  3. mysql_select_db('mytable', $con) or die (mysql_error()); 
  4. $query = 'SELECT content FROM blobdata';
  5. $result = mysql_query($query);
  6. while ($row = mysql_fetch_array($result)){
  7. header("Content-type: image/jpeg");
  8. echo $row['content'];
  9. }
  10. ?>
Nov 12 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
21907
by: Thierry | last post by:
Hello, I do have a mysql database with a BLOB column. What is the proprest way to read this column ? Thx, Thierry
7
7084
by: John | last post by:
I have over 5000 thumbnail pictures of size 5kb each. I would like to able to load all 5000 pictures and view 50 per page using mysql_data_seek(). I would like to know what are the advantages and disadvantages of using a MySQL blob field rather than reading the images directly from the file? How does one insert an image into a blob field? Can it be done dynamically? Thank you John
3
3135
by: NotGiven | last post by:
I am researching the best place to put pictures. I have heard form both sides and I'd like to know why one is better than the other. Many thanks!
4
2236
by: Ellen K | last post by:
Hi all, It was my understanding (Please correct me if I'm wrong on this!) that BLOB data actually reside on their own separate pages and a BLOB field only holds a pointer to the location of the actual data, therefore the BLOB data per se would not get written to the log, only the pointer would be written. If log shipping works by applying the transaction log to the standby database, then what happens to the BLOB data?
3
4714
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
2
1910
by: Luis Mendes | last post by:
How can I read and write images to SQL server to a field with the type "image". Can´t make DataBound work. Thank's in advance, Luis
3
2934
by: =?Utf-8?B?ZGF2aWQ=?= | last post by:
I try to follow Steve's paper to build a database, and store a small text file into SQL Server database and retrieve it later. Only difference between my table and Steve's table is that I use NTEXT datatype for the file instead of using IMAGE datatype. I can not use SqlDataReader to read the data. I need your help, Thanks. -David (1) I have a table TestFile for testing: ID int FileName navrchar(255)
4
7237
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
4241
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
8266
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
8705
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...
1
8365
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
8505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7196
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...
0
5574
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4092
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
4198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2626
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.