0

I am trying to display some images from Mysql database (in phpmyadmin) with PHP.

I used this line of code but this does not work. I have declared $image as follows:

$image=$row['picture'];

I used the following line to display images:

<?php echo "<img src='assets/img/termekek/'.$image'.png'>";?>

but this does not work. Can someone help me?

AmmoPT
  • 958
  • 1
  • 9
  • 16

1 Answers1

2

Your echo defines its string by double-quotes but you try to concatenate using simple quotes, your var gets interpreted (because of double quotes), but has extra characters that aren't (the simple quotes and concatenation chars). Try using simple quotes on your echo and use double quotes on your src attribute :

<?php echo '<img src="assets/img/termekek/'. $image. '.png">';

You can also just use double quotes and insert the variable in your string :

<?php echo "<img src='assets/img/termekek/$image.png'>";
linkboss
  • 656
  • 4
  • 7
  • @AndrasSzilagyi As such, it could be nice to [accept](https://stackoverflow.com/help/someone-answers) linkboss answer – Lex Lustor Aug 24 '18 at 14:37