PHP script being run twice...

    Date: 10/30/06 (PHP Community)    Keywords: database

    So, my problem is that my script seems to be running twice for no apparent reason. I'm not sure what the problem is in the slightest, so here's an over kill explanation about my script;

    Firstly, the script is for a game I'm making - it's basically a map for user to move around on. Obviously I've not added any of the fun stuff to it yet because I want to get the basics of "walking" out of the way first. The map is a grid consisting of 100 squares (10x10), made up by images of rocks, grass, etc. The user needs to be able to move north, east, south and west, and their position is shown by a little avatar in the centre of the map (unless they get too close to the edge, in which case the map stops "scrolling" though the user can still walk up to the edge of the map. If you followed that, well done.

    Secondly, what's in database `game_map`. `user_map` is where information regarding the user is kept. Whilst I'm testing scripts the test user_id is 9. "curr_x_co" is the current user's position of "x" and "curr_y_co" is the same, but for "y".

    Thirdly, here's the script.

    Okay so here's what happens when I run the script. Stats first:

    Previous Location: x 4, y 11
    Current Location: x 4, y 11


    At the moment, they're the same since I've not attempted to move anywhere. If I chose to go right, I would expect the database to be updated with "y" being 11 still but "x" increasing by one to 5. So I press right.

    Previous Location: x 4, y 11
    Current Location: x 5, y 11


    Looking good. Nothing wrong so far. If I press right again, "y" should stay the same, though "x" should become 6. So I press right again.

    Previous Location: x 6, y 11
    Current Location: x 7, y 11


    Huh? It's just jumped two place right, when it should have only added one to "x". But the "Previous location" tells us that it did indeed go to 6, like it was supposed to at some point. This means that the script must have run twice. If I press right once more, it should become 8.

    Previous Location: x 8, y 11
    Current Location: x 9, y 11


    Nope, somehow the script has run twice again, and skipped showing "x=8". Anyone have any idea why it would be doing this?

    Thanks enormously for your time, even if you don't have a clue what I've just said, or what the problem is.

    Source: http://community.livejournal.com/php/506241.html

« GD2 artefact || Header help »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home