Hi all,
I use glossy.js and I am trying to apply it in an image with the path like

<img src="../Users/admin/header1.gif" class="glossy"/>

the effect is ok.

But when I am trying this in a php code like

echo '<img src="../Users/$user[username]/$photo[filename]" class="glossy"/>';

then it does not work.

I have checked $user[username], $photo[filename]

What am I doing wrong ?

thanks in advance

Recommended Answers

All 2 Replies

Member Avatar for diafol

You can't enclose variables inside single quotes:

This'll work:

echo '<img src="../Users/' . $user['username'] . '/' . $photo['filename'] . '" class="glossy"/>';

As will this:

echo "<img src=\"../Users/{$user['username']}/{$photo['filename']}\" class=\"glossy\" />";

Unless I've made some typos.

If you include array variables within double quotes, they must be 'braced out' ({...})

Thanks a lot

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.