1

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()'?

Eddie
  • 26,593
  • 6
  • 36
  • 58

2 Answers2

1

the better one is:

var anyVariable = <?php echo json_encode($anyVariable); ?>;

It will handle correctly strings, booleans, numbers and arrays.

Liglo App
  • 3,719
  • 4
  • 30
  • 54
0

you can echo it

var playername = <?php echo $playername;?>

then you can use the var playername for your js.

Hope this help.

Eddie
  • 26,593
  • 6
  • 36
  • 58