0
/* 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
    }

At the moment this isn't doing any of these things:

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

Is there a better way to do this?

Editing!

$comp_name = "$subformat_$subgame_$subname_$subseason";
        $_SESSION['comp_name'] = $comp_name;

This code is only generating whats in $subseason? Is there an obvious reason for this?

Further editing!

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
    }

And the function 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);
}

any ideas?

How i pass..

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

And this sends them to the function the addLeagueInformation is sent to!

2 Answers 2

5

== is a comparison operator but e.g. in $_SESSION['players'] == $subplayers; you want the assignment operator =
Maybe you also have an issue with $comp_name == '$format_$game_$name_$season';. In single-quoted strings php does not substitute variables.

Sign up to request clarification or add additional context in comments.

1 Comment

And the same goes for the following several lines
1

Is there a better way to do this?

Actually perform the assignments?

$_SESSION['players'] = $subplayers;
// ------------------^ one '=' instead of two '==' (which is for comparison).
$comp_name = "{$format}_{$game}_{$name}_{$season}";
// double quotes to allow substitution,
// {...} to avoid interpreting the variable name as `$format_`.
$_SESSION['comp_name'] = $comp_name;

And make sure addLeagueInformation really return a non-false value in your test if you expect them to be executed.

8 Comments

This helped, but i dont think $comp_name = '$format_$game_$name_$season'; is working?
@Luke: You need double quotes.
@Luke: Updated answer. And see also php.net/manual/en/….
That has stopped it working. I will provide more code in my question.
Edited question further...those {} ended up giving me just underscores!
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.