Displaying an image from inside Mysql database..

This is a discussion on Displaying an image from inside Mysql database.. within the PHP Language forums, part of the PHP Programming Forums category; Ok. what I want to do, is have pictures as BLOBS in a database. And show them onscreen. If I ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-14-2007
The Natural Philosopher
 
Posts: n/a
Default Displaying an image from inside Mysql database..


Ok. what I want to do, is have pictures as BLOBS in a database.

And show them onscreen.

If I have a generic program called say - showpic.php - which is capable
of spitting out an image suitable for downloading, and I write a bit of
HTML like

<IMG URL="showpic.php?id=1112233456">Picture of item 1112233456</IMG>

where the id is and index to the actual picture I want, for example,
will that work?
Reply With Quote
  #2 (permalink)  
Old 09-14-2007
Captain Paralytic
 
Posts: n/a
Default Re: Displaying an image from inside Mysql database..

On 14 Sep, 11:55, The Natural Philosopher <a...@b.c> wrote:
> Ok. what I want to do, is have pictures as BLOBS in a database.
>
> And show them onscreen.
>
> If I have a generic program called say - showpic.php - which is capable
> of spitting out an image suitable for downloading, and I write a bit of
> HTML like
>
> <IMG URL="showpic.php?id=1112233456">Picture of item 1112233456</IMG>
>
> where the id is and index to the actual picture I want, for example,
> will that work?


It will only work if the script executed from showpic.php reads the
data from the database and sends it with the correct headers to the
browser.

Reply With Quote
  #3 (permalink)  
Old 09-14-2007
The Natural Philosopher
 
Posts: n/a
Default Re: Displaying an image from inside Mysql database..

Captain Paralytic wrote:
> On 14 Sep, 11:55, The Natural Philosopher <a...@b.c> wrote:
>> Ok. what I want to do, is have pictures as BLOBS in a database.
>>
>> And show them onscreen.
>>
>> If I have a generic program called say - showpic.php - which is capable
>> of spitting out an image suitable for downloading, and I write a bit of
>> HTML like
>>
>> <IMG URL="showpic.php?id=1112233456">Picture of item 1112233456</IMG>
>>
>> where the id is and index to the actual picture I want, for example,
>> will that work?

>
> It will only work if the script executed from showpic.php reads the
> data from the database and sends it with the correct headers to the
> browser.
>

Thanks buddy!

That is down to debugging, that's all.

How does the browser know if its a jpeg or a gif? Mime type I guess? OK.
That all makes sense.
Reply With Quote
  #4 (permalink)  
Old 09-14-2007
Michael Fesser
 
Posts: n/a
Default Re: Displaying an image from inside Mysql database..

..oO(The Natural Philosopher)

>How does the browser know if its a jpeg or a gif? Mime type I guess?


Correct. For example

header('Content-Type: image/jpeg');

Micha
Reply With Quote
  #5 (permalink)  
Old 09-14-2007
The Natural Philosopher
 
Posts: n/a
Default Re: Displaying an image from inside Mysql database..

Michael Fesser wrote:
> .oO(The Natural Philosopher)
>
>> How does the browser know if its a jpeg or a gif? Mime type I guess?

>
> Correct. For example
>
> header('Content-Type: image/jpeg');
>
> Micha

Ok. Thats all coded in now anyway. I'll test later. Many thanks all.
Reply With Quote
  #6 (permalink)  
Old 09-14-2007
Captain Paralytic
 
Posts: n/a
Default Re: Displaying an image from inside Mysql database..

On 14 Sep, 15:00, The Natural Philosopher <a...@b.c> wrote:
> Michael Fesser wrote:
> > .oO(The Natural Philosopher)

>
> >> How does the browser know if its a jpeg or a gif? Mime type I guess?

>
> > Correct. For example

>
> > header('Content-Type: image/jpeg');

>
> > Micha

>
> Ok. Thats all coded in now anyway. I'll test later. Many thanks all.


BTW, I used this as a resource to save writing it all from scratch:

http://www.onlamp.com/pub/a/onlamp/2...09/webdb2.html

Reply With Quote
  #7 (permalink)  
Old 09-15-2007
The Natural Philosopher
 
Posts: n/a
Default Re: Displaying an image from inside Mysql database..

Captain Paralytic wrote:
> On 14 Sep, 15:00, The Natural Philosopher <a...@b.c> wrote:
>> Michael Fesser wrote:
>>> .oO(The Natural Philosopher)
>>>> How does the browser know if its a jpeg or a gif? Mime type I guess?
>>> Correct. For example
>>> header('Content-Type: image/jpeg');
>>> Micha

>> Ok. Thats all coded in now anyway. I'll test later. Many thanks all.

>
> BTW, I used this as a resource to save writing it all from scratch:
>
> http://www.onlamp.com/pub/a/onlamp/2...09/webdb2.html
>

Well I've done it all, but it still doesn't work.

On safari a direct call to the program nets me a question mark graphic,
in Firefox it just echoes the browser URL..

Inside teh actual display I just get a fractured graphic symbol..


Reply With Quote
  #8 (permalink)  
Old 09-15-2007
The Natural Philosopher
 
Posts: n/a
Default Re: Displaying an image from inside Mysql database..

The Natural Philosopher wrote:
> Captain Paralytic wrote:
>> On 14 Sep, 15:00, The Natural Philosopher <a...@b.c> wrote:
>>> Michael Fesser wrote:
>>>> .oO(The Natural Philosopher)
>>>>> How does the browser know if its a jpeg or a gif? Mime type I guess?
>>>> Correct. For example
>>>> header('Content-Type: image/jpeg');
>>>> Micha
>>> Ok. Thats all coded in now anyway. I'll test later. Many thanks all.

>>
>> BTW, I used this as a resource to save writing it all from scratch:
>>
>> http://www.onlamp.com/pub/a/onlamp/2...09/webdb2.html
>>

> Well I've done it all, but it still doesn't work.
>
> On safari a direct call to the program nets me a question mark graphic,
> in Firefox it just echoes the browser URL..
>
> Inside teh actual display I just get a fractured graphic symbol..
>
>

Oh..it works inside the program now, but not as a standalone. Hmm.

I had an SQL permissions problem..
Reply With Quote
  #9 (permalink)  
Old 09-18-2007
Erwin Moller
 
Posts: n/a
Default Re: Displaying an image from inside Mysql database..

The Natural Philosopher wrote:
> The Natural Philosopher wrote:
>> Captain Paralytic wrote:
>>> On 14 Sep, 15:00, The Natural Philosopher <a...@b.c> wrote:
>>>> Michael Fesser wrote:
>>>>> .oO(The Natural Philosopher)
>>>>>> How does the browser know if its a jpeg or a gif? Mime type I guess?
>>>>> Correct. For example
>>>>> header('Content-Type: image/jpeg');
>>>>> Micha
>>>> Ok. Thats all coded in now anyway. I'll test later. Many thanks all.
>>>
>>> BTW, I used this as a resource to save writing it all from scratch:
>>>
>>> http://www.onlamp.com/pub/a/onlamp/2...09/webdb2.html
>>>

>> Well I've done it all, but it still doesn't work.
>>
>> On safari a direct call to the program nets me a question mark
>> graphic, in Firefox it just echoes the browser URL..
>>
>> Inside teh actual display I just get a fractured graphic symbol..
>>
>>

> Oh..it works inside the program now, but not as a standalone. Hmm.
>
> I had an SQL permissions problem..


Hi,

A little tip that saved me some time during the type of work you do now:
If you think your script is screwing up somewhere, and you want to see
the errors, simply change the header for mimetype into text/plain, and
call the image directly from the browser.

You won't see the image, but you will see notices and such.
(Of course you can also look into the errorlog, but that is such a hassle)
Once you receive a bunch a data that doesn't make sense, you propably
have the image delivered, and it is time to put the old header back. ;-)

Regards,
Erwin Moller
Reply With Quote
  #10 (permalink)  
Old 09-18-2007
The Natural Philosopher
 
Posts: n/a
Default Re: Displaying an image from inside Mysql database..

Erwin Moller wrote:
> The Natural Philosopher wrote:
>> The Natural Philosopher wrote:
>>> Captain Paralytic wrote:
>>>> On 14 Sep, 15:00, The Natural Philosopher <a...@b.c> wrote:
>>>>> Michael Fesser wrote:
>>>>>> .oO(The Natural Philosopher)
>>>>>>> How does the browser know if its a jpeg or a gif? Mime type I guess?
>>>>>> Correct. For example
>>>>>> header('Content-Type: image/jpeg');
>>>>>> Micha
>>>>> Ok. Thats all coded in now anyway. I'll test later. Many thanks all.
>>>>
>>>> BTW, I used this as a resource to save writing it all from scratch:
>>>>
>>>> http://www.onlamp.com/pub/a/onlamp/2...09/webdb2.html
>>>>
>>> Well I've done it all, but it still doesn't work.
>>>
>>> On safari a direct call to the program nets me a question mark
>>> graphic, in Firefox it just echoes the browser URL..
>>>
>>> Inside teh actual display I just get a fractured graphic symbol..
>>>
>>>

>> Oh..it works inside the program now, but not as a standalone. Hmm.
>>
>> I had an SQL permissions problem..

>
> Hi,
>
> A little tip that saved me some time during the type of work you do now:
> If you think your script is screwing up somewhere, and you want to see
> the errors, simply change the header for mimetype into text/plain, and
> call the image directly from the browser.
>
> You won't see the image, but you will see notices and such.
> (Of course you can also look into the errorlog, but that is such a hassle)
> Once you receive a bunch a data that doesn't make sense, you propably
> have the image delivered, and it is time to put the old header back. ;-)
>
> Regards,
> Erwin Moller


Mm. I sorta did that.

There were two issues..one is my test database had not got the right
permissions - there is something odd gong on because according to my
understanding the user had full rights, but I had to give that user full
rights in the database as well. Odd. Anyway that was half the problem.

The second half is that while the image now pops up when and IMG tag is
wrapped round it, a direct call to the image sender program results in a
file download, not an image being displayed..well I haven;t go time to
delve into either if those issues right now, so they stand..
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:51 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0