Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: "while" loop

  1. #1
    Regular Coder
    Join Date
    Feb 2003
    Location
    East Side/West Side
    Posts
    118
    Thanks
    0
    Thanked 0 Times in 0 Posts

    "while" loop

    There seems to be a problem with a loop in my PHP program.

    Please download the file (as I have no clue how to use this board's attachment system - I have problems like that all the time)(and it's way too big to post) at http://ionic-empire.ionic-rebellion.net/dm.zip

    The code selects a game out of the database, and then runs certain procedures for each game. It's supposed to loop through the games with the game IDs of 1-3 (in my case). The problem is it's only running games with the IDs of 1 and 3, but not 2. Does there seem to be any problems with my loop?
    Last edited by Phantom; 04-15-2003 at 01:09 AM.
    Rule #1 - Admin is always right
    Rule #2 - If Admin is wrong, see rule #1

  • #2
    Regular Coder
    Join Date
    Feb 2003
    Location
    California
    Posts
    925
    Thanks
    0
    Thanked 0 Times in 0 Posts
    by the way, your link is wrong....its supposed to be http://ionic-empire.ionic-rebellion....wnloads/dm.zip


    Jason

  • #3
    Regular Coder
    Join Date
    Feb 2003
    Location
    California
    Posts
    925
    Thanks
    0
    Thanked 0 Times in 0 Posts
    there might be a problem just before the while loop, not so much with the syntax. Try and echo out what the data is in $game1[ ] before the while loop to know that "2" is in there. From the looks of it to me, it should work. If there were to be a problem I would say its not doing game 1 or maybe game 3...but I see no reason for game 2 to have a problem.

    Jason

  • #4
    Regular Coder
    Join Date
    Feb 2003
    Location
    East Side/West Side
    Posts
    118
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The output prints out "1", prints out everything it does, and then prints out (for $game[game_id]) "3"

    I changed the end of the loop to
    PHP Code:
    $s_g_a $s_g_a 1;
    db("select * from se_games where paused = 0 && game_id = $s_g_a");

    $game dbr();
    echo 
    $game[game_id]; 
    if $s_g_a is 1, then shouldn't it be 2 and not 3?
    Rule #1 - Admin is always right
    Rule #2 - If Admin is wrong, see rule #1

  • #5
    Regular Coder
    Join Date
    Feb 2003
    Location
    East Side/West Side
    Posts
    118
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Seems the only fix I could think of was

    PHP Code:
    if($s_g_a == 1) {
       
    $s_g_a == 2
    } elseif(
    $s_g_a == 2) {
      
    $s_g_a == 3;

    Not very pretty, but hey, if it works, it works
    Rule #1 - Admin is always right
    Rule #2 - If Admin is wrong, see rule #1


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •