Forum Moderators: coopster

Message Too Old, No Replies

Showing image file from the database

         

AranhaHunter

3:48 am on Sep 19, 2005 (gmt 0)

10+ Year Member



I'm having some trouble showing an imagefile that I have on the database. I have the following code line

<img src="images/<?php echo $row_Records['imagefile'];?>">

However, I don't see a picture on there when I test it (Mozilla and IE). I see the following on the source from the browser:

<img src="images/"bookcase.jpg>

I can't seem to figure this out and any help would be appreciated.

dkin

5:40 am on Sep 19, 2005 (gmt 0)

10+ Year Member



what does the row in your database say?

R e b r a n d t

6:26 am on Sep 19, 2005 (gmt 0)



Your code is quite.. NOT LOGIC!

First <img ...> tag is for image address, so the browser can fetch the image. And NOT the image itself.

In your situation it should be something like:

<img src="image.php">

Then you should create image.php script where you would echo the image data (dont forget to set image headers as well).

Here is some working example:
[onlamp.com...]

dkin

7:17 am on Sep 19, 2005 (gmt 0)

10+ Year Member



thats only if he is storing the actual image in the database, if he is simply uploading the file and keeping the file name in the db his "logic" is fine.

R e b r a n d t

8:08 am on Sep 19, 2005 (gmt 0)



Well yes.

I assumed that 'imagefile' is the image itself, not the image filename. \-:

AranhaHunter

9:08 am on Sep 19, 2005 (gmt 0)

10+ Year Member



Sorry for the confusion. Dkin got it, Rebrandt, imagefile is the filename, and I'm trying to upload the file.

Anyways, I created the table with the following command

CREATE TABLE items (name VARCHAR(30), imagefile VARCHAR(30));

and I inserted the row as follows:
INSERT INTO items VALUES ('"Bookcase"','"bookcase.jpg"');

Hopefully that will clear all confusion :)

EDIT: Nevermind guys, dkin, you were right, it was the database row, I took out the quotation marks and it worked.

dkin

10:33 am on Sep 19, 2005 (gmt 0)

10+ Year Member



glad to help.