are you sure there is no white space getting returned in your echo? if you have a line break (which you can't "see" in the returned value) that could be throwing off the img src tag
maybe wash the returned value through a function stripping off leading and trailing whitespace http://www.google.com/search?hl=en&q=javascript+strip+whitespace