tags:

views:

20

answers:

1
        //loop through usernames to add to league table
    for ($i = 0; $i < count($user); $i++)
    {
        //set some new variables in an array
        $username = $user[$i];
        $squad = $team[$i];
        //add details to league table
        if ( $username != "Ghost")
        {
            $database->addUsersToLeagueTable($username, $squad);
        }
    }   

I use this code to add to the league table, the following is more code:

   function addUsersToLeagueTable($username, $squad)
   {
    $q = "INSERT INTO `$_SESSION[comp_name]` ( `user` , `team` ,    `home_games_played` , `home_wins` , `home_draws` , `home_losses` ,`home_points,     `home_goals_for` , `home_goals_against` , `away_games_played` , `away_wins` , `away_draws` , `away_losses` , `away_points` , `away_goals_for` , `away_goals_against` )
    VALUES (
    '$username', '$squad', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0')";
    return mysql_query($q, $this->connection);

}

Can you see any obvious reason why this isn't happening? Thanks

+3  A: 

SQL error stands out to me:

INSERT INTO `$_SESSION[comp_name]` ( `user` , `team` ,    `home_games_played` , `home_wins` , `home_draws` , `home_losses` ,`home_points,     `home_goals_for` , `home_goals_against`

You're missing a back tic after home_points.

Jage
And this is why error checking is important.
Ignacio Vazquez-Abrams
@Jage, Thankyou, that solved my program@ignacio, error checking?
Luke