Smudly Posted July 3, 2010 Share Posted July 3, 2010 I'm having a slight problem setting an img tag in a variable. This variable will be called later in the page. $avatar = $uploadrow['avatar']; $avatarshow = "<img src=\'/avatars/$avatar\' width=\'100\' height=\'100\'>"; Now I am certain the problem is with my syntax in the avatarshow variable. I tested it by typing out the full name of the file, and it is shown just fine. But doing it this way causes problems. Any suggestions on fixing this code? (I'm not getting any mysql errors) Link to comment https://forums.phpfreaks.com/topic/206610-syntax-issues/ Share on other sites More sharing options...
joel24 Posted July 3, 2010 Share Posted July 3, 2010 you're backslashing single quotes when the string is held within double quotes. you only need to backslash double quotes within double quotes and single quotes within single quotes. and for the directory avatars, you just need avatars/imageName.jpg, not /avatars/imagename.jpg and i'm assuming "avatar" field in the database stores the image suffix - .jpg, .gif etc? i.e. $avatar = $uploadrow['avatar']; $avatarshow = "<img src='avatars/$avatar' width='100' height='100'>"; Link to comment https://forums.phpfreaks.com/topic/206610-syntax-issues/#findComment-1080595 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.