473,441 Members | 1,905 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,441 software developers and data experts.

publish JPEG or HTML from a database

I have a jpeg file and a HTML page that are stored in two separate
blob fields of a databses, namely interbase, what is the best method
of pulling each of these items out so that they can be displayed in a
web browser.
Jul 17 '05 #1
7 4192
UnixUser wrote:
I have a jpeg file and a HTML page that are stored in two separate
blob fields of a databses, namely interbase, what is the best method
of pulling each of these items out so that they can be displayed in a
web browser.


The method that has worked for me for dispalying images is:

show_image.php
--------------
<?php
header('Content-type: image/jpeg');
$query='SELECT field_name FROM table_name WHERE id = '.$_GET['id'];
// add your database code to perform query and store
// data in $data variable
echo $data;
?>

Then in the HTML, I use:
<img src="show_image.php?id=24" alt="">

You can do the same with HTML, but your Content-type should be
'text/html' instead.

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.

Jul 17 '05 #2
Image files are commonly displayed from a MySQL database by linking to
another php page . . .

<image src ="display_image.php?imageid=<?php echo $yourimageid; ?>";

Your display image page (display_image.php in this case)

<?
require("config.inc");
$sql = "SELECT src FROM images WHERE id=\"$id\"";
$result = mysql_query($sql,$connection) or die("Couldn't execute get sector
types query");
while ($row = mysql_fetch_array($result)) {
$src = $row['src'];
}
echo $src;
?>

I'm not sure about the HTML in a BLOB field but I assume it would be roughly
the same . . .

-Jamie

On 11/14/03 1:34 PM, in article
a1**************************@posting.google.com, "UnixUser"
<ra*********@pfshouston.com> wrote:
I have a jpeg file and a HTML page that are stored in two separate
blob fields of a databses, namely interbase, what is the best method
of pulling each of these items out so that they can be displayed in a
web browser.


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 17 '05 #3
Jamie Davison wrote:
<img src="display_image.php?imageid=<?php echo $yourimageid; ?>";

Your display image page (display_image.php in this case)

<?
require("config.inc");
$sql = "SELECT src FROM images WHERE id=\"$id\"";
$result = mysql_query($sql,$connection) or die("Couldn't execute get sector
types query");
while ($row = mysql_fetch_array($result)) {
$src = $row['src'];
}
echo $src;
?>


This would display garbage on the screen... You need to send header
information for the Content-type (see my previous post).

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.

Jul 17 '05 #4
I might have been a bit unclear. You must link "to" the display_image.php
page from the calling php page with
<img src="display_image.php?imageid=<?php echo $yourimageid; ?>">

I have used this same format with greatb success . . .

JD

On 11/14/03 2:18 PM, in article pU****************@news7.onvoy.net, "Justin
Koivisto" <sp**@koivi.com> wrote:
Jamie Davison wrote:
<img src="display_image.php?imageid=<?php echo $yourimageid; ?>">

Your display image page (display_image.php in this case)

<?
require("config.inc");
$sql = "SELECT src FROM images WHERE id=\"$id\"";
$result = mysql_query($sql,$connection) or die("Couldn't execute get sector
types query");
while ($row = mysql_fetch_array($result)) {
$src = $row['src'];
}
echo $src;
?>


This would display garbage on the screen... You need to send header
information for the Content-type (see my previous post).


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 17 '05 #5
Jamie Davison wrote:
On 11/14/03 2:18 PM, in article pU****************@news7.onvoy.net, "Justin
Koivisto" <sp**@koivi.com> wrote:

Jamie Davison wrote:
<img src="display_image.php?imageid=<?php echo $yourimageid; ?>">

Your display image page (display_image.php in this case)

<?
require("config.inc");
$sql = "SELECT src FROM images WHERE id=\"$id\"";
$result = mysql_query($sql,$connection) or die("Couldn't execute get sector
types query");
while ($row = mysql_fetch_array($result)) {
$src = $row['src'];
}
echo $src;
?>
This would display garbage on the screen... You need to send header
information for the Content-type (see my previous post).


**Fixed top-posting **
I might have been a bit unclear. You must link "to" the display_image.php
page from the calling php page with
<img src="display_image.php?imageid=<?php echo $yourimageid; ?>">

I have used this same format with greatb success . . .


See my post that came in just before yours....

In any case, you still need to send the content-type headers for the
browsers to display the image properly, or you will get a blank image.
Maybe *some* browsers will automatically figure it out, but when I first
did this, if the header wasn't sent, the image didn't display.

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.

Jul 17 '05 #6
Where you you include this "content-type" header? I have used the very
method below many times and never had to sent a content header simply
because PHP and HTML expect an image from the <img src> tag.

-JD


On 11/14/03 3:41 PM, in article j6****************@news7.onvoy.net, "Justin
Koivisto" <sp**@koivi.com> wrote:
Jamie Davison wrote:
On 11/14/03 2:18 PM, in article pU****************@news7.onvoy.net, "Justin
Koivisto" <sp**@koivi.com> wrote:

Jamie Davison wrote:

<img src="display_image.php?imageid=<?php echo $yourimageid; ?>">

Your display image page (display_image.php in this case)

<?
require("config.inc");
$sql = "SELECT src FROM images WHERE id=\"$id\"";
$result = mysql_query($sql,$connection) or die("Couldn't execute get sector
types query");
while ($row = mysql_fetch_array($result)) {
$src = $row['src'];
}
echo $src;
?>

This would display garbage on the screen... You need to send header
information for the Content-type (see my previous post).


**Fixed top-posting **
I might have been a bit unclear. You must link "to" the display_image.php
page from the calling php page with
<img src="display_image.php?imageid=<?php echo $yourimageid; ?>">

I have used this same format with greatb success . . .


See my post that came in just before yours....

In any case, you still need to send the content-type headers for the
browsers to display the image properly, or you will get a blank image.
Maybe *some* browsers will automatically figure it out, but when I first
did this, if the header wasn't sent, the image didn't display.


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 17 '05 #7
Jamie Davison wrote:
Where you you include this "content-type" header? I have used the very
method below many times and never had to sent a content header simply
because PHP and HTML expect an image from the <img src> tag.


Check my reply to the OP

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.

Jul 17 '05 #8

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

Similar topics

0
by: UnixUser | last post by:
I am using the PHP 4.3.4 with a standard (unmodified ) php.ini file. I am tryong to output a blob field that contains a jpeg image using the ibase_blob_echo( row) function. I am presently...
16
by: David Lauberts | last post by:
Hi Wonder if someone has some words of wisdom. I have a access 2002 form that contains 2 graph objects that overlay each other and would like to export them as a JPEG to use in a presentation....
4
by: Rednelle | last post by:
Greetings all, As a newbie, using Access 2000, I would appreciate advice on the best way to include pictures. I have developed a 'Home Inventory' database which can include jpeg thumbnails of...
2
by: Lucas Cowald | last post by:
Hi, Using ASP and VBScript. How to convert JPEG image into a binary data? Is it possible with a command from ASP / VBScript without having to put it into a database first? I want to take the...
3
by: RobertH | last post by:
Hello all. I have been hacking away trying to get a SQL image (jpeg) to render in a control or table row Without using the Response.BinaryWrite.... I think i might be on the verge but need a...
9
by: Tim | last post by:
Since rtf files cause so many troubles, i.e., allow the users to download the files, slow loading, incompatible with other browser, and so on. Do you think I should convert them to JPEG files to...
1
by: Masood | last post by:
Greetings, We are writing an application wherein we have to display jpeg images, we are thinking of using the IJG JPEG LIB written in C code. Will be greatfull if someone could guide us as to...
0
by: Open Publish 2007 | last post by:
CONFERENCE PROGRAM AND KEYNOTE PRESENTERS HAVE JUST BEEN ANNOUNCED FOR OPEN PUBLISH 2007. http://www.open-conferences.com/baltimore/sched-at-a-glance.html Open Publish 2007, bringing together...
0
by: =?Utf-8?B?TWFyazEyMw==?= | last post by:
I have two pieces of VB.NET code below: a) Sends an email b) Returns a programmatically created jpeg image to a webpage. How can I embed the programmatically created jpeg into an HTML...
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
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...
0
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...
0
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...
0
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...
0
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.