Jump to content

syntax issues


Smudly

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.