Skip navigation
Noschlitz
Currently Being Moderated

Retrieve an Image for recordset

Feb 24, 2013 4:04 PM

After test-uploading data with a form, I can see my image files located in my server directory, and I can see the file name in my sql database.  However, I use the code:

<td><img src="<?php echo $row_Recordset1['Image']; ?>" alt="No Image to Display" name="" width="120" height="120" /></td>

and cannot see the image (although I can se the other data) n my recordset.

 

I have also tried several combinations, like:

<td><img src="./<?php echo $row_Recordset1['Image']; ?>" alt="If there's an image, it would be here" name="" width="120" height="120" /></td>

and

<td><img src="./images/<?php echo $row_Recordset1['Image']; ?>" alt="If there's an image, it would be here" name="" width="120" height="120" /></td>

 

The placeholder for the image is there...

It looks like the sql image file name is truncated.  Is there a specific field type, collation or attribute that I should be using instead of varchar, utf8_general__ci?

Any help would be greatly appreciated.

 
Replies
  • Currently Being Moderated
    Feb 24, 2013 5:20 PM   in reply to Noschlitz

    Can you show us what the code rendered from the browser for one record looks like? That way we can see how the php code is being interpreted.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 24, 2013 9:10 PM   in reply to Noschlitz

    No, show us the code, not the image.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 25, 2013 7:51 AM   in reply to Noschlitz

    You're using document relative referencing for the images. Is the image folder located at the same level as the folder that this page is on?  Or is the page located at the site root?

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 25, 2013 10:14 AM   in reply to Noschlitz

    As a test try including the absolute url to the image like below:

     

    If locally testing:

     

    <img src="localhost/websiteFoldername/imageFolderName/<?php echo $row_Recordset1['Image']; ?>

     

    If remote:

     

    <img src="http://www.websiteName.com/imageFolderName/<?php echo $row_Recordset1['Image']; ?>

     

     

    If you don't see an image when using the full url then there's something incorrect in your database (check the image name has a .jpg extention).

     

    If you do see an image as I expect you should then you have to get the link path to the image correct if you don't want to use the absolute url. It might be ../

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 25, 2013 1:49 PM   in reply to Noschlitz

    >I have pasted the structure below.  As you can see, there is one HTML folder.

    >All other folders reside at the next level, including my images folder.

     

    None of your attachment have worked. Is the php document you are working with located in the site root folder, or in a subfolder?

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 25, 2013 7:05 PM   in reply to Noschlitz

    >Yes, the php document is located in the site root folder. 

    >Additionally, the images folder is located at that same level.

     

    <img src="./images/katie's camera fall 2011 036.JPG"

     

     

    Your path is not correct. If the doc is at root level, that path is telling the browser to move up one level -  which is not valid- before moving down to the image folder. You're better off using root relative paths for this. Just remove the preceeding dot in the path.  If you want to continue using doc relative paths, remove the preceeding dot and slash. You should probably become more familiar with server path syntax. I would also suggest not have filenames with spaces in them.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 25, 2013 11:53 PM   in reply to Noschlitz

    Noschlitz wrote:

     

    When inspecing the code, it looks like the correct file is inserted into the code from the mySQL database, just no picture.

    Frustrating

     

    So when you view the code you see the absolute path followed by the name of the image?

     

    You say you are testing remotely. Type the absolute path to this image directly in the browser url bar, does it show up?

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 26, 2013 7:29 AM   in reply to Noschlitz

    If it does not show up then its not in the location the link thinks its in.

     

    As a test make a copy of the image and place it directly in your site folder then do another absolute link test:

     

    http://www.yourWebsiteAddress.com/nameOfImage.jpg

     

    If it doesn't show up then there is something wrong with the image (check the color space is saved as RGB and not CMYK)

     

    If it does show up it means that the path to the image is incorrect in your original test file.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 26, 2013 9:51 AM   in reply to Noschlitz

    Yes, your image source must point to exactly where the image resides. Your browser code showed this:

     

    <img src="./images/katie's camera fall 2011 036.JPG

     

    which means you have not embedded the full path in your database - there is no UPLOAD folder in your path. You also need to fix the document relative path problem I mentioned earlier.  Finally, you mention that your images are in a folder named UPLOADS under the  IMAGES folder. But your recordset shows a lowercase 'images' folder. *nix servers are case sensitive so you need to be sure the cases match exactly. So it looks like you have several problems you need to address.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 26, 2013 11:25 PM   in reply to Noschlitz

    Two things may be happening here;

     

    1) The column type (Length Value) in your database may not be set to receive as many characters as the image name has. What have you got set?

     

    2) How are you uploading the images to the uploads folder? If through a form and upload script the script many be attaching a series of randon numbers to stop images already uploaded with potentially the same name being overwritten.

     

    I'd first have a look at what you have set in the Length Value column of your database.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 27, 2013 9:14 AM   in reply to Noschlitz

    So are you saying you are manually inserting the image information into the database field as 120_035.jpg

     

    then using the upload facility to select 120_035.jpg and that get uploaded as: 120_0351361934386.jpg

     

    or are you saying the automated upload facility inserts the image name into the database BUT truncates it to 120_035.jpg

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 27, 2013 9:41 AM   in reply to Noschlitz

    Well it appears as though the original uploaded image from your computer 120_035.jpg information is being inserted into the database before the additional numbers are getting added. When the additional numbers have been added the image then gets moved to the upload images folder.

     

    That creates a problem because the recordset only sees 120_035.jpg and not the longer number, so the image can't be found as it no longer exists as 120_035.jpg

     

    You have to try and find a way of not letting the information get uploaded to the database before the extra number have been added.

     

    Was moving the image to the database part of the upload package you bought. If so you will probably have to go back to them and ask why this is happening. Maybe there's a way to stop it adding the random set of numbers to the original image name, which would also solve the issue but then there is the potential for an image to be overwritten. All these upload facilities should come with a error warning anyway if there is a duplicated name in the upload folder.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points