No one could possibly have any idea what's wrong there (other than a lucky guess), because we're not seeing your actual code.
Forget about PHP for the moment and look at what you get back from a View Source in the browser. That's all the browser and its JavaScript interpreter know about - your PHP source is out of the picture at that point. Do you see what's wrong there? If not, then please post a link to a live test page (not just a code snippet) and I'm sure someone will be able to spot the problem. -Mike > From: suntrop > > When write: > $('#' + id + ' img').attr("src", "images/favorites.png"); . it works. > alert (msg) says "favorites". > > There must be something wrong with msg. If the variable is > defined before var favimg = "favorites"; and I insert favimg > it works just fine. > > What could be wrong with msg? msg is what I echo back in my PHP code. > I don't know if this is the appropriate way. > On 22 Sep., 13:34, MorningZ <[EMAIL PROTECTED]> wrote: > > "But the image isn't replaced correctly" > > > > Perhaps try changing this line instead > > > > $('#' + id + ' img').attr("src", "images/"+msg+".png"); > > > > There's no reason why that (or your line for that matter) wouldn't > > work as long as the selector finds something and the value of the > > "src" is a valid path on your server >