characters are causing errors in the console

re:neo

New Member
\[quote\] Possible Duplicate:
PHP: How should I escape a string that will be going into a Javascript String? \[/quote\]I have a situation with a characters. If I type in a piece of text (a question) which multiple characters such as:\[quote\] !\"?$%^&()-=\'.,:;/?#~/\\><\[/quote\]Then I suddenly receive an error stating:\[quote\] Syntax error: unterminated string literal\[/quote\]Then it displays this in the console:\[quote\] parent.addwindow('!/;\[/quote\]My question is that can I change anything in the code below to allow these characters for the question?Below is the code:\[code\] foreach ($searchResults as $key=>$question) { echo '<tr class="questiontd"><td>'.htmlspecialchars($question).'</td>'; echo '<td class="optiontypetd">'.htmlspecialchars($searchOption[$key]).'</td>'; echo '<td class="noofanswerstd">'.htmlspecialchars($searchNoofAnswers[$key]).'</td>'; echo '<td class="answertd">'.htmlspecialchars($searchAnswer[$key]).'</td>'; echo '<td class="noofrepliestd">'.htmlspecialchars($searchReply[$key]).'</td>'; echo '<td class="noofmarkstd">'.htmlspecialchars($searchMarks[$key]).'</td>'; echo "<td class='addtd'><button type='button' class='add' onclick=\"parent.addwindow('$question','$searchMarks[$key]','$searchNoofAnswers[$key]','$searchOption[$key]','$searchReply[$key]','$searchAnswer[$key]');\">Add</button></td></tr>";} echo "</table>"; } }?>\[/code\]You can view the application here: ApplicationWhen you open the app, simply click on the green plus button on the left hand side, when the modal window appears. Enter in \[code\]?\[/code\] in the search bar and enter the search. You will see a bunch of results. Now all the rows look fine except for the row which contains \[code\]>!\"?$%^&*()-=\'.,:;/?#~*/\\\\><\[/code\], The "Add" button in that row is messed up and if you try clicking on that add button, then you get the error which already mentioned in top of the question.
 
Back
Top