PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have a button on my site that when clicked fills in a textarea. Everything works fine unless the content in variable $row["fill"] has a line break. Then I get an JavaScript error.
A line break should show up fine inside of a textarea. That's not the problem, I wouldn't think.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Oh, I see what you're saying. you could str_replace() the line breaks (PHP_EOL)
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Typically these problems are caused when your outputted PHP code contains a single or double quote...have you tried escaping the string before echo'ing it to the JS string ?
Unlike C, whitespace in JavaScript source can directly impact semantics. Because of a technique called "semicolon insertion", any statement that is well formed when a newline is parsed will be considered complete (as if a semicolon were inserted just prior to the newline).
When I encountered it in variable assignment I got the same weirdness. The following code (maintaining whitespace):
Syntax error while loading: line 1165 of inline script at ... :
itemsinfo["descr"][384]="White Single Cuff Ring
------------------------------------------------^
because the value had a newline in it.
As suggested, stripping out newline chars (cater for all OSs) should fix the problem.