0

i have this problem i hope some of you can help me with. I try to make a html link that get the link from my database.

echo "<p><pre><a href=$Feed['socialfacebook']><img src=facebook-24.png></a></pre></p>  
tadman
  • 208,517
  • 23
  • 234
  • 262
Anoxy
  • 873
  • 7
  • 17

5 Answers5

2

You need to put the link in '".$variable ."' and the image src should be in ' ', too.

echo "<p><pre><a href='".$Feed['socialfacebook']."'><img src='facebook-24.png'></a></pre></p>";
baao
  • 71,625
  • 17
  • 143
  • 203
1
  • Close your string with a double quote and end your statement with a semi-colon,
  • When getting array elements inside a string literal like you're doing, leave out the key quotes,
  • Use single quotes around your attribute in case of any spaces:
echo "<p><pre><a href='$Feed[socialfacebook]'><img src=facebook-24.png></a>";

Eval.in

George
  • 36,413
  • 9
  • 66
  • 103
1

Double-quoted strings don't work with array elements quite like that. You should close and concatenate the strings.

echo "<p><pre><a href=".$Feed['socialfacebook']."><img src=facebook-24.png></a></pre></p>"

You might also want to put some quotes on your attributes.

vpzomtrrfrt
  • 483
  • 6
  • 16
  • This worked perfectly! i will accept it in 6 minutes when stackoverflow allows me too! thank you so much! and thanks to all of you guys! – Anoxy Oct 23 '14 at 15:29
  • 1
    This answer actually missed the quotes for the html attributes – Brewal Oct 23 '14 at 15:36
0

u need to put the variable $Feed['socialfacebook'] in " . $Feed['socialfacebook'] ."

echo "<p><pre><a href=" . $Feed['socialfacebook'] . "<img src=facebook-24.png></a></pre></p>";

and don't forget the ;

Yassine
  • 35
  • 7
-1

Shouldn't it be:

echo "<p><pre><a href='$Feed["socialfacebook"]'><img src=facebook-24.png></a>";

Don't forget that is href="".

azhpo
  • 43
  • 10