unemployment Posted August 31, 2011 Share Posted August 31, 2011 I can't figure out how to write the a href part to make it blend in with the existing img syntax. How do I alter this? <?php echo '<a href=\"{$r['feedusername']\"><img src="', getUserAvatar($r['feedusername']), "\" class=\"avatar mediumsmall newspadding f_left mrl\" title=\"${r['associate_name']}\" alt=\"${r['associate_name']}\" /></a>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/246110-href-echo-syntax-is-wrong/ Share on other sites More sharing options...
Pikachu2000 Posted August 31, 2011 Share Posted August 31, 2011 Look at your quotes. Variables aren't interpolated within single-quoted strings. Quote Link to comment https://forums.phpfreaks.com/topic/246110-href-echo-syntax-is-wrong/#findComment-1263931 Share on other sites More sharing options...
WebStyles Posted August 31, 2011 Share Posted August 31, 2011 This should work. (Because I'm combining two types of quotes, there's no need to escape the double quotes here) <?php echo '<a href="'.$r['feedusername'].'"><img src="'.getUserAvatar($r['feedusername']).'" class="avatar mediumsmall newspadding f_left mrl" title="'.$r['associate_name'].'" alt="'.$r['associate_name'].'" /></a>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/246110-href-echo-syntax-is-wrong/#findComment-1263932 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.