Skip to main content
Known Participant
March 22, 2012
Question

trouble echoing image

  • March 22, 2012
  • 1 reply
  • 534 views

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?

This topic has been closed for replies.

1 reply

Participating Frequently
March 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>";

Known Participant
March 22, 2012

close

if($attachment == 1) {

    echo "<img src=

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

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

}

echo "</td>";

thanks though!

Participating Frequently
March 22, 2012

Ah yes, I am always misplacing my semi colons.