What you have above is a mix of script that will run whenever, mingled with a PHP value that doesnt exist once the page is rendered.
Without knowing context, there is not way to help you. Is this generated from the PHP? Is this written on the page and expected to execute? Is this a dynaimcally created script that loads via a src?
There are too many variables to really understand what you are trying to do.