When I first read the title of your post, I wondered why you were asking about JavaScript. Then I read it and realized you were just looking for help putting code into your php file (which could have been anything). Now, I come to one last realization and that is that you didn't post your code (how you are trying to insert the code, so we can help you tweak it...)
You say "i put this in the end of the file but b4 the ?>"... well why not just put it ouside of the ?> Otherwise, if you choose to echo, you should wrap it in single-quotes.
Either way, you may want to show us how you are trying to put this code in, so we can help you out better.