Announcement

Collapse
No announcement yet.

Problem with a URL as a $ variable

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with a URL as a $ variable

    I have a minor problem that is driving me mad.

    Basically I am making a blog system for my site, and at the moment there only being two users, the system for getting which user is easy, eg, if it is not A it must be B.

    This code gets the user info and assigns that to the $avatar variable so that I can echo that back in some img tags.

    PHP Code:
    if (($row->postedby)==UserA) {
    $avatar='http://pathtoserver/avatar1.gif';
    }
    else
    {
    $avatar='http://pathtoserver/avatar2.gif';

    Now, it works ok, except that it adds a ; to the end of the URL...

    so I get <img src="http://pathtoserver/avatar1.gif;">

    Any ideas? Please?

  • #2
    Your code seems to be ok (except you should quote "UserA" if it's a string), so it must be a problem in the line you echo $avatar.

    PHP Code:
    echo '<img src="'.$avatar.'" alt="Avatar" />'
    Should work fine.
    Chen Avinadav
    Better to remain silent and be thought a fool than to speak out and remove all doubt.

    גם אני מאוכזב מסיקור תחרות לתור מוטור של NRG הרשת ע"י מעריב

    Comment


    • #3
      Originally posted by FireFly
      PHP Code:
      echo '<img src="'.$avatar.'" alt="Avatar" />'
      Should work fine.
      And indeed it now does. Thank you very much kind sir.

      Comment


      • #4
        You're welcome.
        Chen Avinadav
        Better to remain silent and be thought a fool than to speak out and remove all doubt.

        גם אני מאוכזב מסיקור תחרות לתור מוטור של NRG הרשת ע"י מעריב

        Comment

        widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
        Working...
        X