Images do not display, when image path is returned as a String, which includes a variable.
<p>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).</p>

<p>code</p>

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

<p>When I var_dump $path, it displays the correct file path: <code>string(28) "../images/thumbs/image1.jpeg"</code>, 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.</p>

<pre><code>echo '&lt;li&gt;&lt;img src="../images/thumbs/image1.jpg"/&gt;&lt;/li&gt;';
</code></pre>

<p>also I have tried removing the $path varible and applying $row directly:</p>

<pre><code>echo '&lt;li&gt;&lt;img src="../images/thumbs/'.$row['image_path'].'"/&gt;&lt;/li&gt;';
</code></pre>

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

<pre><code> $full_path = $path . $row['image_path'];
</code></pre>

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

<pre><code>string(11) "image1.jpeg" string(11) "image2.jpeg" string(11) .....
</code></pre>

<p>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.</p>
