Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As watcher said, PHP does not do variable interpolation within single-quoted strings.</p> <blockquote> <p>The most important feature of double-quoted strings is the fact that variable names will be expanded.</p> </blockquote> <p><a href="http://ca.php.net/manual/en/language.types.string.php" rel="nofollow">Read more about strings from the PHP manual.</a></p> <p>Therefore, when you view the HTML, you will <em>literally</em> see this:</p> <pre><code>&lt;img src="$image" height="50" width="50" /&gt; </code></pre> <p>Your code should be:</p> <pre><code>while($result = mysql_fetch_array($resul,MYSQL_ASSOC)) { $image = $result['image']; echo $result['company'] . " " . $result['model'] . "&lt;br&gt;"; echo "&lt;img src='$image' height='50' width='50'&gt;"; } </code></pre> <p>Alternatively, interpolate the array value:</p> <pre><code>while($result = mysql_fetch_array($resul,MYSQL_ASSOC)) { echo $result['company'] . " " . $result['model'] . "&lt;br&gt;"; echo "&lt;img src='{$result['image']}' height='50' width='50'&gt;"; } </code></pre> <p>If the filename contains spaces or other special characters, you may need to use <a href="http://ca.php.net/manual/en/function.rawurlencode.php" rel="nofollow"><code>rawurlencode()</code></a>. In this case, you <strong>must</strong> concatenate the string since you are calling a function that returns a <code>string</code> value:</p> <pre><code>echo "&lt;img src='" . rawurlencode($result['image']) . "' height='50' width='50'&gt;"; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload