By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,985 Members | 1,777 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,985 IT Pros & Developers. It's quick & easy.

publish JPEG or HTML from a database

P: n/a
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
Share this Question
Share on Google+
7 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.