Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

PHP outputting a string into javascript

Avatar of winglis4
winglis4 asked on
PHP
7 Comments1 Solution3964 ViewsLast Modified:
Hello,
I have a problem with having php output a string into javascript.
I need to take the contents of a textfield (that is stored in a db) and output a javascript 'safe' string. The trouble I'm having is if the user used the "Enter" key to begin a new line, the javascript string breaks and I get a 'unterminated string literal' error.

I have tried using php's str_replace() to replace \n with "" but no luck.

Anyone know about this and how I can get rid of this error?
Thanks,
Will
ASKER CERTIFIED SOLUTION
Avatar of Zyloch
Commented:
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answers