PHP/MYSQL Help [Solved]

Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.
Post Reply
User avatar
MikeD
Posts: 294
Joined: Thu Sep 08, 2011 4:28 am

PHP/MYSQL Help [Solved]

Post by MikeD »

I don't even understand this.

On my local server...

Code: Select all

$Get_Games = mysqli_query($db,"SELECT * FROM `games` WHERE `season`='$Server_Season' AND `day`='$Server_Day' AND `time`='$Server_Game' AND `status`=0") or die(mysqli_error($db));
while ($row = mysqli_fetch_row($Get_Games)){

    $Get_Game = mysqli_query($db,"SELECT `status` FROM `games` WHERE `game_id`='$row[0]'") or die(mysqli_error($db));
    $Status = mysqli_fetch_array($Get_Game);

    if ($Status['status'] == 0){

        include 'sim/college/sim/sim.php';
    }

}
That does exactly what I want, it finds all the 175 Different games to sim at that particular time and runs them. However, on my LIVE server, it is only running the result of the same game 175 times. Does anybody know why? It's the same exact code... I'm beyond confused/annoyed by this.
Last edited by MikeD on Sat Mar 23, 2013 1:50 pm, edited 1 time in total.
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: PHP/MYSQL Help Urgent

Post by Jackolantern »

The $row[0] is not likely the issue. A different value is being stored in $row each iteration of the WHILE loop, and that index of 0 is merely pointing to a piece of data from each of them.

Honestly, this is a tough one. Since it worked fine on your development machine and is now breaking on the live server, that tells me there could be an issue in the DB. Do you have access to a phpMyAdmin panel, a MySQL console or something for your database? If so, try running that same query alone and see what results you get. That will tell you which side the error is on, whether it is in the database or somehow in the PHP logic.
The indelible lord of tl;dr
User avatar
MikeD
Posts: 294
Joined: Thu Sep 08, 2011 4:28 am

Re: PHP/MYSQL Help Urgent

Post by MikeD »

Thanks for the help. I got it fixed.

I pasted that code into it's own page, and it started to grab the correct game IDs, but still only running the same game. So it was there that I learned the difference between "include_once" and "include." I was "Including_Once" the globals page that held the game_id and team IDs, so every game was using that same Game_Id and Team IDs. I'm not sure how an Include got changed to an Include_Once when I uploaded through FTP.
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: PHP/MYSQL Help [Solved]

Post by Jackolantern »

Oh yes, there is a huge difference between them. Most of the time devs actually use include_once() since you only want to include libraries once, so I think some IDEs can be a little jumpy about "correcting" include() to include_once().
The indelible lord of tl;dr
Post Reply

Return to “Advanced Help and Support”