Connecting Tech Pros Worldwide Help | Site Map

publish JPEG or HTML from a database

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 01:08 AM
UnixUser
Guest
 
Posts: n/a
Default 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.

  #2  
Old July 17th, 2005, 01:08 AM
Justin Koivisto
Guest
 
Posts: n/a
Default Re: publish JPEG or HTML from a database

UnixUser wrote:[color=blue]
> 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.[/color]

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 - spam@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.

  #3  
Old July 17th, 2005, 01:08 AM
Jamie Davison
Guest
 
Posts: n/a
Default Re: publish JPEG or HTML from a database

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
a1c0482e.0311141034.65f6f6a2@posting.google.com, "UnixUser"
<rafel.coyle@pfshouston.com> wrote:
[color=blue]
> 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.[/color]



-----= 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! =-----
  #4  
Old July 17th, 2005, 01:08 AM
Justin Koivisto
Guest
 
Posts: n/a
Default Re: publish JPEG or HTML from a database

Jamie Davison wrote:[color=blue]
> <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;
> ?>[/color]

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

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

  #5  
Old July 17th, 2005, 01:08 AM
Jamie Davison
Guest
 
Posts: n/a
Default Re: publish JPEG or HTML from a database

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 pU9tb.912$Uz.26563@news7.onvoy.net, "Justin
Koivisto" <spam@koivi.com> wrote:
[color=blue]
> Jamie Davison wrote:[color=green]
>> <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;
>> ?>[/color]
>
> This would display garbage on the screen... You need to send header
> information for the Content-type (see my previous post).[/color]



-----= 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! =-----
  #6  
Old July 17th, 2005, 01:08 AM
Justin Koivisto
Guest
 
Posts: n/a
Default Re: publish JPEG or HTML from a database

Jamie Davison wrote:
[color=blue]
> On 11/14/03 2:18 PM, in article pU9tb.912$Uz.26563@news7.onvoy.net, "Justin
> Koivisto" <spam@koivi.com> wrote:
>
>[color=green]
>>Jamie Davison wrote:
>>[color=darkred]
>>><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;
>>>?>[/color]
>>
>>This would display garbage on the screen... You need to send header
>>information for the Content-type (see my previous post).[/color]
>[/color]

**Fixed top-posting **
[color=blue]
> 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 . . .[/color]

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 - spam@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.

  #7  
Old July 17th, 2005, 01:08 AM
Jamie Davison
Guest
 
Posts: n/a
Default Re: publish JPEG or HTML from a database

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 j6btb.915$Uz.26871@news7.onvoy.net, "Justin
Koivisto" <spam@koivi.com> wrote:
[color=blue]
> Jamie Davison wrote:
>[color=green]
>> On 11/14/03 2:18 PM, in article pU9tb.912$Uz.26563@news7.onvoy.net, "Justin
>> Koivisto" <spam@koivi.com> wrote:
>>
>>[color=darkred]
>>> 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).[/color]
>>[/color]
>
> **Fixed top-posting **
>[color=green]
>> 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 . . .[/color]
>
> 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.[/color]



-----= 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! =-----
  #8  
Old July 17th, 2005, 01:08 AM
Justin Koivisto
Guest
 
Posts: n/a
Default Re: publish JPEG or HTML from a database

Jamie Davison wrote:[color=blue]
> 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.[/color]

Check my reply to the OP

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

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.