Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6825251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:59:59+00:00 2026-05-26T21:59:59+00:00

I am having problems displaying images which have been queried from the database. The

  • 0

I am having problems displaying images which have been queried from the database. The array from the query result is looped through and the image name is extracted, then passed to a variable which also contains the image path. However when the variable is included in the output, a torn image icon is displayed (no image).

Code:

public function loadImages($item) {
  $type = $item;
  $conn = $this->create_connection('read');
  $sql = "SELECT * FROM `items` WHERE catagory='$type'";     
  $result = $conn->query($sql)or die(mysql_error());    
  while($row = mysqli_fetch_array($result)) {
     $path = '../images/thumbs/'.$row['image_path'];
     //var_dump($path);
     echo '<li><img src="../images/thumbs/'.$path.'"/></li>';
  }

When I var_dump $path, it displays the correct file path: string(28) "../images/thumbs/image1.jpeg", with a further seven items, so I am not losing data. I can confirm the path is correct, when I echo the full path and image name, the image displays correctly.

echo '<li><img src="../images/thumbs/image1.jpg"/></li>';

Also I have tried removing the $path variable and applying $row directly:

echo '<li><img src="../images/thumbs/'.$row['image_path'].'"/></li>';

I thought the problem was with joining the two strings, so I tried replacing the image variable with $full_path, which also did not work:

 $full_path = $path . $row['image_path'];

$row is correct because when I do a var-dump for $row['image_path'] I get the following:

string(11) "image1.jpeg" string(11) "image2.jpeg" string(11) .....

I previously had the full image path held within the database, when the full image path was used, the images displayed correctly. I later decided only to store the image name in the database, as the path could change in the future, so the design change created this problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:00:00+00:00Added an answer on May 26, 2026 at 10:00 pm
    while($row = mysqli_fetch_array($result)) {
         $path = '../images/thumbs/'.$row['image_path'];
         //var_dump($path);
         echo '<li><img src="../images/thumbs/'.$path.'"/></li>';
    }
    

    $path already contains “../images/thumbs/”, but you add it again when echoing the line.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im having a problem with removing non-utf8 characters from string, which are not displaying
I am having problem in displaying Tiff images in browser.I have my images stored
Im having problems displaying records to my view when passing viewdata to a user
hey there, Im having problems displaying my results in this program but the program
I'm having some problems displaying the contents of one NSArrayController in two windows defined
I'm having a problem displaying data from a function to text box within a
My problem is that I have a user that is having a problem displaying
Im having problems building a query with the linq to sql data query expression
I am having problems with my sidebar_box , as it is displaying a unwanted
For so many time, I have encountered problems with managing image having abnormally long

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.