构造if,if else,else语句

sar*_*012 0 php

/* Errors exist, have user correct them */
    if($form->num_errors > 0)
    {
         return 1;  //Errors with form
    }
     /* No errors, add the new account to the */
    else if($database->addLeagueInformation($subname, $subformat, $subgame, $subseason, $subwindow, $subadmin, $subchampion, $subtype))
    {
        $database->addLeagueTable();
        $_SESSION['players'] == $subplayers;
        $comp_name == '$format_$game_$name_$season';
        $_SESSION['comp_name'] == $comp_name;
        return 0;  //New user added succesfully
    }
    else
    {
        return 2;  //Registration attempt failed
    }
Run Code Online (Sandbox Code Playgroud)

目前这还没有做以下任何事情:

$database->addLeagueTable();
    $_SESSION['players'] == $subplayers;
    $comp_name == '$format_$game_$name_$season';
    $_SESSION['comp_name'] == $comp_name;
Run Code Online (Sandbox Code Playgroud)

有一个更好的方法吗?

编辑!

$comp_name = "$subformat_$subgame_$subname_$subseason";
        $_SESSION['comp_name'] = $comp_name;
Run Code Online (Sandbox Code Playgroud)

这段代码只在$ subseason中产生什么?这有明显的原因吗?

进一步编辑!

else if($database->addLeagueInformation($subname, $subformat, $subgame, $subseason, $subwindow, $subadmin, $subchampion, $subtype))
    {
        $_SESSION['players'] = $subplayers;
        $comp_name = "$subformat_$subgame_$subname_$subseason";
        $_SESSION['comp_name'] = $comp_name;
        $database->addLeagueTable();
        return 0;  //New user added succesfully
    }
Run Code Online (Sandbox Code Playgroud)

和函数addLeagueTable()

function addLeagueTable() {
   $q = "CREATE TABLE `$_SESSION[comp_name]` (
     `user` VARCHAR( 30 ) NOT NULL ,
        `team` VARCHAR( 40 ) NOT NULL ,
        `home_games_played` INT( 3 ) NULL DEFAULT '0',
        `home_wins` INT( 3 ) NULL DEFAULT '0',
        `home_draws` INT( 3 ) NULL DEFAULT '0',
        `home_losses` INT( 3 ) NULL DEFAULT '0',
        `home_points` INT( 3 ) NULL DEFAULT '0',
        `home_goals_for` INT( 3 ) NULL DEFAULT '0',
        `home_goals_against` INT( 3 ) NULL DEFAULT '0',
        `away_games_played` INT( 3 ) NULL DEFAULT '0',
        `away_wins` INT( 3 ) NULL DEFAULT '0',
        `away_draws` INT( 3 ) NULL DEFAULT '0',
        `away_losses` INT( 3 ) NULL DEFAULT '0',
        `away_points` INT( 3 ) NULL DEFAULT '0',
        `away_goals_for` INT( 3 ) NULL DEFAULT '0',
        `away_goals_against` INT( 3 )  NULL DEFAULT '0'
        )";
   return mysql_query($q, $this->connection);
}
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

我怎么过...

      $retval = $session->createLeague($_POST['name'], $_POST['players'], $_POST['format'], $_POST['game'], $_POST['season'], $_POST['window'], $_POST['admin'], $_POST['champion'], $_POST['type']);
Run Code Online (Sandbox Code Playgroud)

这将它们发送到addLeagueInformation发送给的函数!

Vol*_*erK 5

==是一个比较运算符,但例如$_SESSION['players'] == $subplayers;你想要赋值运算符=
也许你也有问题$comp_name == '$format_$game_$name_$season';.在单引号字符串中,php不替换变量.