Reputation: 125
I'm trying to create a cookie in JavaScript, but it isn't working. All the stuff works, but I'm having problems with JavaScript.
This is the code for my page. The mysql connection works well, I've just masked the entries. http://pastebin.com/HfbZyVQZ
How do I can use the '$playername'
with the 'setPlayer()'
?
Upvotes: 1
Views: 57
Reputation: 3819
the better one is:
var anyVariable = <?php echo json_encode($anyVariable); ?>;
It will handle correctly strings, booleans, numbers and arrays.
Upvotes: 1
Reputation: 26854
you can echo it
var playername = <?php echo $playername;?>
then you can use the var playername for your js.
Hope this help.
Upvotes: 0