473,394 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 37037
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_query($sql,$conn);
$img=mysql_fetch_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=something"> or whatever
//... get the blob code....
header("Content-type: image/jpeg");
echo image blob;
exit;
?>

"Rob" <ro***************@sbcglobal.net> wrote in message news:<dK*****************@newssvr29.news.prodigy.c om>...
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_getting_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.478412$Ho3.80600@sccrnsc03>...
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=something"> or whatever
//... get the blob code....
header("Content-type: image/jpeg");
echo image blob;
exit;
?>

"Rob" <ro***************@sbcglobal.net> wrote in message news:<dK*****************@newssvr29.news.prodigy.c om>...
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.net...
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
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...
3
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
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...
10
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...
35
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
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...
4
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...
10
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...
3
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...

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.