#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    3
    Rep Power
    0

    This query works in phpmyadmin, but not when the page runs.


    This query works in php my admin, but not when the page runs. Any ideas? I have tried error reporting, but that does not turn up with anything at all.
    PHP Code:
    $sql "SELECT the_forum_league_games.id, the_forum_league_pairings.weekno, users1.username AS user1name, users1.user_id AS user1id, users2.username AS user2name, users2.user_id AS user2id, the_forum_league_games.result
        FROM the_forum_league_games
        LEFT JOIN the_forum_users 
        AS users1
        ON users1.user_id=the_forum_league_games.player1
        LEFT JOIN the_forum_users 
        AS users2
        ON users2.user_id=the_forum_league_games.player2
        LEFT JOIN the_forum_league_pairings
        ON the_forum_league_pairings.id=the_forum_league_games.pairing_id
        WHERE the_forum_league_pairings.seasonid='
    $season_number'
        ORDER BY the_forum_league_pairings.weekno, the_forum_league_games.player1"

  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,183
    Rep Power
    9398
    If the SQL works fine then clearly the problem is not with the SQL, yes?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    3
    Rep Power
    0

    Perhaps


    Perhaps, I am really not sure.

    The full code is:
    PHP Code:
    $sql "SELECT the_forum_league_games.id, the_forum_league_pairings.weekno, users1.username AS user1name, users1.user_id AS user1id, users2.username AS user2name, users2.user_id AS user2id, the_forum_league_games.result 
        FROM the_forum_league_games 
        LEFT JOIN the_forum_users  
        AS users1 
        ON users1.user_id=the_forum_league_games.player1 
        LEFT JOIN the_forum_users  
        AS users2 
        ON users2.user_id=the_forum_league_games.player2 
        LEFT JOIN the_forum_league_pairings 
        ON the_forum_league_pairings.id=the_forum_league_games.pairing_id 
        WHERE the_forum_league_pairings.seasonid='
    $season_number
        ORDER BY the_forum_league_pairings.weekno, the_forum_league_games.player1"
    ;
    $result $db->sql_query($sql);
        while (
    $row $db->sql_fetchrow($result))
        {
            
    $weekno_arr[] = $row['weekno'];
            
    $player1_arr[] = $row['user1id'];
            
    $player1_arr[] = $row['user2id'];
            
    $username1_arr[] = $row['user1name'];
            
    $username2_arr[] = $row['user2name'];
            
    $result_arr[] = $row['result'];
            
    $gameid_arr[] = $row['id'];
        } 
  6. #4
  7. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,183
    Rep Power
    9398
    Looks fine so far, though your arrays are a bit wonky.

    Why do you say it doesn't work? Because there's no output? Could it be that the outputting is what's wrong?
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    3
    Rep Power
    0

    Nope


    PHP Code:
    echo $row['user2name']; //outputs nothing 
    When I put that echo statement in the while loop, it fails to print any results. Very strange! Any more ideas?
  10. #6
  11. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,183
    Rep Power
    9398
    Is $season_number being set correctly? If it's not what you did earlier, echo out $sql and try that verbatim.

    Next step would be to try debugging in $db. Maybe there's an error from the database you aren't seeing/outputting.
  12. #7
  13. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Sep 2003
    Location
    Germany
    Posts
    1,355
    Rep Power
    323
    PHP Code:
    print_r($row
    or
    PHP Code:
    var_dump($row
    in your while loop and see if that outputs something.
    IkoTikashi - ikotikashi.de

IMN logo majestic logo threadwatch logo seochat tools logo