473,782 Members | 2,465 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP mySQL image blobs

Rob
Ummm...I'm a little stuck on how to approach the following....

I have a mySQL table holding images (fields are: data (blob), name (text),
type (text), size(text), desc (text) )

If I want to show the image on a page (they're all jpg's), how do I do I
implement this?

Uploading, downloading, text listing it is easy...I'm just wondering how I
SHOW it. :-)

I'm completely brain-frozen on this.

Thanks in advance,
Robert
Jul 16 '05 #1
5 37059
Rob wrote:
I have a mySQL table holding images (fields are: data (blob), name (text),
type (text), size(text), desc (text) )
If I want to show the image on a page (they're all jpg's), how do I do I
implement this?


just print them:
header ("Content-type: image/jpeg");
$sql="select blobfield from table where ...";
$result=mysql_q uery($sql,$conn );
$img=mysql_fetc h_row($result);
print $img[0];

Dana


Jul 16 '05 #2
<?php
// perhaps called get_image.php.. .
// pass $_GET params to specify image or session vars... etc..
// instead of <IMG src="image.jpg" > it's <IMG
src="get_image. php?image=somet hing"> or whatever
//... get the blob code....
header("Content-type: image/jpeg");
echo image blob;
exit;
?>

"Rob" <ro************ ***@sbcglobal.n et> wrote in message news:<dK******* **********@news svr29.news.prod igy.com>...
Ummm...I'm a little stuck on how to approach the following....

I have a mySQL table holding images (fields are: data (blob), name (text),
type (text), size(text), desc (text) )

If I want to show the image on a page (they're all jpg's), how do I do I
implement this?

Uploading, downloading, text listing it is easy...I'm just wondering how I
SHOW it. :-)

I'm completely brain-frozen on this.

Thanks in advance,
Robert

Jul 16 '05 #3
?? this has been answered

<!-- surrounding html -->
<IMG src="image_gett ing_script.php? image=whatever" >
<!-- and some more -->

are you concerned about having a "separate" script for the image
getting?
don't need a separate script... your page-generating script could only
output the image when given certain paramaters...
paul brown <pa**@paulbrown .net> wrote in message news:<ZcO9b.478 412$Ho3.80600@s ccrnsc03>...
Yes, but how would one do it in the context of surrounding it with an
html page, and not just the image itself?

paul
BKDotCom wrote:
<?php
// perhaps called get_image.php.. .
// pass $_GET params to specify image or session vars... etc..
// instead of <IMG src="image.jpg" > it's <IMG
src="get_image. php?image=somet hing"> or whatever
//... get the blob code....
header("Content-type: image/jpeg");
echo image blob;
exit;
?>

"Rob" <ro************ ***@sbcglobal.n et> wrote in message news:<dK******* **********@news svr29.news.prod igy.com>...
Ummm...I'm a little stuck on how to approach the following....

I have a mySQL table holding images (fields are: data (blob), name (text),
type (text), size(text), desc (text) )

If I want to show the image on a page (they're all jpg's), how do I do I
implement this?

Uploading, downloading, text listing it is easy...I'm just wondering how I
SHOW it. :-)

I'm completely brain-frozen on this.

Thanks in advance,
Robert

Jul 17 '05 #4
paul brown wrote:
Yes, but how would one do it in the context of surrounding it with an
html page, and not just the image itself?

paul
BKDotCom wrote:
[snip: answer to question]


BK answered your question (twice), but there's another possible answer
depending on your delivery context. If you're serving pages over WWW,
just use the "img" tag to point to your PHP script that prints the image
(like BK said). However, if you're using PHP to generate a MIME
encoded document (such as an email), you can also put the image data in
the HTML tag (so people aren't requesting a document on your server
every time they open that email message). If you are, in fact, creating
a MIME document, have a look at this article that has really good info
on MIME formats:

http://www.phpbuilder.com/columns/kartic20000807.php3

HTH,
Zac

Jul 17 '05 #5
Rob
Thanks Zac!

Actually, thank you everyone. Just for reference, phpbuilder has another
article for showing images directly from a db, including the PHP scripts...

http://www.phpbuilder.com/columns/fl...14.php3?page=1

But the MIME one you showed was also useful (for another project)
Robert

"Zac Hester" <ne**@planetzac .net> wrote in message
news:3f******** @news.enetis.ne t...
paul brown wrote:
Yes, but how would one do it in the context of surrounding it with an
html page, and not just the image itself?

paul
BKDotCom wrote:
[snip: answer to question]
>>


BK answered your question (twice), but there's another possible answer
depending on your delivery context. If you're serving pages over WWW,
just use the "img" tag to point to your PHP script that prints the image
(like BK said). However, if you're using PHP to generate a MIME
encoded document (such as an email), you can also put the image data in
the HTML tag (so people aren't requesting a document on your server
every time they open that email message). If you are, in fact, creating
a MIME document, have a look at this article that has really good info
on MIME formats:

http://www.phpbuilder.com/columns/kartic20000807.php3

HTH,
Zac

Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3439
by: mir nazim | last post by:
hi, i m facing a problem in properly accesing BLOBs from mysql db. when i display an image stored in the blob field it show some absurd characters. i think it is the problem of properly telling browser the mime type of image of blob field. that is exactly what my problem is. i do not know how to do that . any help is appreciated.
3
3147
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!
1
3661
by: Raaijmakers, Vincent (GE Infrastructure) | last post by:
It is the first time that I use blobs in mysql. Please help me out here..... Using MSSQLdb and python 2.3.4 I was surprised to see how my information was stored in the blob. My goal is to store JPG images in the blob. Well, it stores it but as a string of bytes: 'x0dx0fxffxa3......' So, when reading back that information into my python environment, it seems that I need to translate the value back to the original binary format? ...
10
7406
by: John Smith | last post by:
I know that uploading an image to a database has been covered, oh, about 3 trillion times. However, I haven't found anything covering uploading to a MySQL database with .net. Please don't recommend storing the image to the filesystem and only keeping a pointer to that in the table. I want to dump the image to a table. My code dumps the data into the table, however, I get the following error when trying to view the image "the image ......
35
2676
by: Stan Sainte-Rose | last post by:
Hi, What is the better way to save image into a database ? Just save the path into a field or save the image itself ? I have 20 000 images (~ 10/12 Ko per image ) to save. Stan
3
3491
by: meyvn77 | last post by:
Hello - I am looking for the best way to store images in a Access DB. My Idea - I have a table with 150,000 records. These recoreds represent a Crash (Traffic Accident). I have 50 different images that represent almost any type of Accident. Each crash record can be represented by one of those 50 images (depending on the Crash Data). I don't want to waste space by having each record have a BLOB field w/
4
3801
by: cuyler.jones | last post by:
Hello -- I'm having a heck of a time grabbing a blob ( a jpeg image) from a mySQL database and displaying it on a page. I am able to connect to the database and retrieve the data, however when the page loads, it just spews the binary garbage rather than displaying the image. Here's the code:
10
13414
by: eholz1 | last post by:
Hello Members, I am setting up a photo website. I have decided to use PHP and MySQL. I can load jpeg files into the table (medium blob, or even longtext) and get the image(s) to display without a problem. I am using chunk_split(data) and the base64_encode and base64_decode on the files. I do a select from the database, and then echo the image (with header(Content Type: image/jpeg) and the decoded image displays fine. Yes, I have...
3
5389
by: Taras_96 | last post by:
Hi everyone, I'm having a bit of trouble understanding the purpose of escaping nulls, and the use of addcslashes. Firstly, the manual states that: "Strictly speaking, MySQL requires only that backslash and the quote character used to quote the string in the query be escaped. This function quotes the other characters to make them easier to read in
0
9641
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
9480
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
9944
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
8968
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
6735
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
5378
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
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.