Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 6th, 2011, 07:04 PM
Registered User
 
Join Date: Jul 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
 
Old July 11th, 2011, 12:18 PM
Registered User
 
Join Date: Jul 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Figured it out

I know the answer to my question.

I was using 'GET' when I was opening my xmlhttprequest. This was allowing the response to be cached, and I kept getting my initial response. I changed it to 'POST', and it works.

If anyone knows why opening another internet explorer would cause my initial GET to not cache the response, thus allowing my program to carry on, I would appreciate learning about it.

Thanks.

dal
 
Old July 13th, 2011, 10:30 PM
Registered User
 
Join Date: Jul 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to run php on windows 7

how can i run php file in windows 7 on iis





Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help me to solve these two problem khatu_jec C# 4 January 3rd, 2008 08:41 AM
Need help to solve problem PankajMishra XSLT 7 April 19th, 2007 08:27 AM
HELP! Can anyone solve this problem? JoeR VB How-To 3 September 5th, 2006 09:56 AM
Solve my problem first? wakil C# 3 February 9th, 2006 08:21 AM
could you solve my problem? Robin1 Javascript 0 September 13th, 2004 10:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.