Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

trouble echoing image

Explorer ,
Mar 22, 2012 Mar 22, 2012

I always get confused using " and '.  here is my code, where i am trying to echo out an image:

echo "<td>". if($attachment==1) { echo"<img src='http://mysite.com/images/attachment.png' width='20' height='20' />"; } ."</td>";

How do i rewrite this so I no longer get an error?

TOPICS
Server side applications
539
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 22, 2012 Mar 22, 2012

The code looks completely wrong to me. You're concatenating an IF statement that contains an echo within another echo construnct. I'm not very good with PHP syntax, but try:

echo "<td>";

if($attachment==1) {

     echo "<img src='http://example.com/images/attachment.png' width='20' height='20' />" };

echo "</td>";

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 22, 2012 Mar 22, 2012

close

if($attachment == 1) {

    echo "<img src=

'http://example.com/images/attachment.png

' width='20' height='20' />" ;

}

echo "</td>";

thanks though!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 22, 2012 Mar 22, 2012
LATEST

Ah yes, I am always misplacing my semi colons.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines