Javascript SyntaxError: unterminated string literal

by Subramanian 2014-07-23 17:11:30

Javascript SyntaxError: unterminated string literal:
 

Javascript doesn't support multi-line strings, you'll need to either:

  • make that tag one big line, or
  • use a trailing backslash on each line to indicate "continuation", or
  • use multiple strings joined together.
Mostly this error happen when you assign php variable to javascript variable.
So you need to use mydql_real_escape_string() for php variable befor assign to javascript variable.

Ex:
<script>
var name="<?php echo mysql_real_escape_string("GvSubhu <br />' "); ?>";
</script>
825
like
0
dislike
0
mail
flag

You must LOGIN to add comments