Where do I look to solve the problem?
Old programmer, but new to web programming - teaching myself PHP/Javascript/AJAX/MySQL. I've come across an issue that I would like to have someone point me in the right direction; not necessarily solve it for me. I'm not sure this is the right forum, but it's a start.
Writing a web application for my home network - a word game for me and my kids.
Player 1 opens the page, enters their name, and hits submit. I then XMLHttpRequest to a PHP file, that does a select on a MySQL dataset, looking for any open games based on nothing being in games.player_name_2. The layout of games is:
game_id
player_name_1
player_name_2
Not finding any, I then insert a record, get the game_id, and begin polling every three seconds, until player_name_2 is populated.
This works, sorta. I create the record in the table correctly, and the polling fires off every three seconds. I alert myself the game_id and the opponent name every time, and they show me that my opponent hasn't signed in. I'll get to the sorta part later.
Player 2 opens the page, enters their name, and hits submit. I look for open games as above, find that player 1 is ready to play, update the record. I get confirmation back on this page (I alert myself game_id and opponent name).
Player 1's page continues to poll every three seconds. It continues to act as if Player 2 never entered the game.
Now, keep reading; don't assume that my polling logic is wrong. Remember that 'sorta works' comment earlier? Here's the odd thing. When player 1 opens another Internet Explorer, my game page then gets a response back from XMLHttpRequest with the game_id and the opponent's name.
It sorta works, but only if I open another Internet Explorer.
What are the possible causes of this behavior? Does it sound like a PHP issue? MySQL? AJAX?
I am baffled, and any help would be appreciated. If this belongs elsewhere, please point me there.
Thanks in advance.
dal
|