Parse error when embeding js in php

I seem to be getting the error:

PHP Parse error: syntax error, unexpected ‘(’, expecting T_VARIABLE or ‘$’

when inserting some js code in my php. I think the culprit is the curly brackets within the js, as it occurs on only the 2 lines where they appear:

… function() {$(" …

I’ve tried putting the code into <<<EOF … EOF; but makes no difference

You probably should post your code, it’s hard to tell how your js code is being evaluated by php without seeing the code.

I think its also very likely to be unescaped "

Make sure you replace all " with \"