Reputation: 930
my code:
var custID = <?php echo htmlentities( $_GET['custID'] ); ?>;
I get error in firebug:
SyntaxError: syntax error [Break On This Error] var custID = <br />
Please note: I am not passing a parameter custID.
Upvotes: 0
Views: 77
Reputation: 53198
You need to specify it as a string, if using htmlentities()
:
var custID = '<?php echo htmlentities( $_GET['custID'] ); ?>';
It is also worth noting that you might need to add slashes to the string to prevent it from breaking out of the literal in JS:
var custID = '<?php echo addslashes(htmlentities( $_GET['custID'] )); ?>';
Upvotes: 2