PDA

View Full Version : Problem with a URL as a $ variable


MartynJ
Mon 2nd Sep '02, 6:52pm
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.


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?

Chen
Tue 3rd Sep '02, 9:42am
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.

echo '<img src="'.$avatar.'" alt="Avatar" />';
Should work fine.

MartynJ
Tue 3rd Sep '02, 2:56pm
Originally posted by FireFly
echo '<img src="'.$avatar.'" alt="Avatar" />';
Should work fine. And indeed it now does. Thank you very much kind sir.

Chen
Tue 3rd Sep '02, 3:33pm
You're welcome. :)