SyntaxError: unterminated string literal

0

I have a textarea that is populated with mysql data using .val ()

It turns out that when writing line breaks or spaces in that textarea, it returns the error SyntaxError: unterminated string literal.

so I read here because I have to escape the text closing quotation marks and putting a + but of course I can not do it since it is a dynamic field and if I tell the user that he has to put the + in each line I know he will not do it and he will destroy me on the web.

Is there any way to escape from that?

I've tried using str_replace(array("\r", "\n"), '', $str); and it does not give the error, but it does not do the line breaks and I need them: (

and if I put preg_replace("/\r\n|\r|\n/",'<br />',$str); it changes the spaces for <br/> but when it gets in the textarea it does not interpret them as html and it writes them literally.

    
asked by Killpe 03.02.2017 в 20:43
source

1 answer

1

In the end I just had to change <br /> for \ n and it works now.

It has stayed like this%% of% and all OK

    
answered by 03.02.2017 / 21:29
source