Page 1 of 1

PHP/MYSQL Help [Solved]

Posted: Sat Mar 23, 2013 2:02 am
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.

Re: PHP/MYSQL Help Urgent

Posted: Sat Mar 23, 2013 6:13 am
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.

Re: PHP/MYSQL Help Urgent

Posted: Sat Mar 23, 2013 1:50 pm
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.

Re: PHP/MYSQL Help [Solved]

Posted: Sat Mar 23, 2013 10:56 pm
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().