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) Quote Link to comment 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'>"; Quote Link to comment 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.