Displaying An Image Using A Php Variable
I'm trying to display images by taking their file path from an sql table, but i'm having a lot of troubles. Here is whats going on: $image is a variable containing the text 'itemim
Solution 1:
First of all, you should not use PHP Shorttags.
When you use the PHP Shorttags you have to say:
<img src="<?=$image ?>" alt="test" />
But i would encourage to escape the Content off the variable like this:
<img src="<?php echo htmlspecialchars($image); ?>" alt="test" />
Your extra question:
This should lead to an syntax error because the string could not be parsed, just use $image = $row['image'];
Solution 2:
Try this
<img src= "<?php echo $image ?>" alt="test"/>
Solution 3:
try
<img src= "<?= $image ?>" alt="test"/>
or
<img src= "<? echo $image; ?>" alt="test"/>
Solution 4:
try this
<img src= "<?php echo $image ?>" alt="test"/>
Post a Comment for "Displaying An Image Using A Php Variable"