Image path in MySQL

Hi all,

I’d like to include in my MySQL table a path to an image. The image path gets into the table by inserting the value of a “file” textfield (one of those Browse kind of deals). So the value that gets entered is something like: “image001.jpg”.

So far, the data goes in and when I query it in the MySQL.exe prompt the image name comes up as expected: “image001.jpg”. But I can’t seem to use that value to put an image into a html page. I suppose it has to do with the appearance of a “.” in the table data, but if it goes into the table fine, why can’t I get it out?

In my php page which reads the data and echos it on the screen, I’ve retrieved the table data and put it into a variable ($product_image):

          <p><font face="Arial, Helvetica, sans-serif" size="-1">
            Current image: <?php echo "$product_image"; ?><br>
            <img src="<?php echo 'Uploads/$product_image' ?>"></font></p>
          <p><font size="-1" face="Arial, Helvetica, sans-serif">
            <input type="hidden" name="MAX_FILE_SIZE" value="200000">
            <input type="file" name="userfile" value="<?php echo '$product_image'; ?>" size="50">

but all I get in the browser is the red x indicating no image to load, and where it echos “Current image: <?php echo “$product_image”; ?>” I get:
“Current image: Uploads//image001.jpg”.
I haven’t even used “Uploads//” anywhere in the code but it adds it in anyway.

I’ll reiterate that the data in the table is simply a file name with extension, eg “image001.jpg”. Not “Uploads/image001.jpg” and not “/image001.jpg”.

And yes, I’ve checked that the image uploads to the Uploads folder.

If someone’s got some good advice for using image names or paths in MySQL table data I’d be grateful.

Thanks for your time.

use the root folder notation for both files.

<?php echo “./$product_image” ?>

Could you post the code where you retrieve the file name from your MySQL table (basically any processing you do to the $product_image variable).

Thanks for your help but I got it sorted. I just had to escape the forward slash in the path: $destination = “Uploads/”;

thanks anyway.