Skip to content Skip to sidebar Skip to footer

Php Generated Content Inside Javascript Breaking Script

I have a website with some Javascript rotating content with a fade. The script works fine until I add a PHP while loop inside it, then it fails. I'm using the PHP to pull content f

Solution 1:

Your problem is the one unescaped linebreak in the quotes:

"\&nbsp;&nbsp;&nbsp;&nbsp;<p>this is a good web test</p><divid='quoteauthor'>Ben Harrison</div>",

This is not valid JavaScript. You have to escape it somehow, for example like by using str_replace() in the PHP functions, that create those strings.

str_replace("\n","&nbsp;",$string)

Post a Comment for "Php Generated Content Inside Javascript Breaking Script"