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>  
1
  • It looks like you're missing the double quote at the end. Commented Oct 23, 2014 at 15:23

5 Answers 5

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>";
Sign up to request clarification or add additional context in comments.

2 Comments

Just copy the entire code, works exactly like it should
Don't forget the closing "; at the end, you did in your question
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.

2 Comments

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!
This answer actually missed the quotes for the html attributes
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

2 Comments

Do you know any difference between "<a href='$array[key]'>", "<a href='{$array["key"]}'>" and "<a href='".$array['key']."'>" besides readability (performance, compatibility version, ...) ?
@Brewal See this question: stackoverflow.com/questions/16790501/…
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 ;

Comments

-1

Shouldn't it be:

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

Don't forget that is href="".

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.