Hi, hoping someone can help. I run a small site for my local football club and use a stats php set of scripts to keep player and match stats through the season. The admin section allows me to set the default view to the current season which should show the 2005/06 matches list or 2005/06 players list depending on which you choose to view from the relevant link. The database contains details for past seasons which can be selected from a pull down selection menu. I’ve used to programme for several seasons with no problems but for some reason I find that now the default view isn’t working correctly. Sometimes the scripts are displayed as they should be, sometimes it doesn’t find any of the data at all but I can then obtain the current season data by using the pulldown menu, sometimes the script displays all the data for this season and last season. It does this quite randomly and other visitors are complaining of the same problem.

The scripts are located here:
http://www.portisheadafc.co.uk/tpl2_first/index.php

This is the bit of code that sets the default view:

if(!session_is_registered('defaultseasonid_tplss') || !session_is_registered('defaultmatchtypeid_tplss') || !session_is_registered('defaultlanguage_tplss'))
{
$SESSION['defaultseasonid_tplss']=$pdata['DefaultSeasonID'];
$
SESSION['defaultmatchtypeid_tplss']=$pdata['DefaultMatchTypeID'];
$SESSION['defaultlanguage_tplss']=$pdata['DefaultLanguage'];
$defaultseasonid=$
SESSION['defaultseasonid_tplss'];
$defaultmatchtypeid=$SESSION['defaultmatchtypeid_tplss'];
$defaultlanguage=$
SESSION['defaultlanguage_tplss'];
}
else
{
$defaultseasonid=$SESSION['defaultseasonid_tplss'];
$defaultmatchtypeid=$
SESSION['defaultmatchtypeid_tplss'];
$defaultlanguage=$_SESSION['defaultlanguage_tplss'];
}

Hope I’ve included all I need to. I’m tearing my hair out and hoping someone can help

Steve Hyde

    Use $SESSION or session_register() function but not both. Seriously, use one or the other. Don't mix using a session variable and session_register() in the same script. Note that session_register() function requires that the 'register_globals' setting be on for it to work (which is a security risk). Avoid having 'register_globals' on and using session_register() and related functions such as session_is_registered() and session_unregister(). For PHP version 4.1.0 and higher it's recommend to just use $SESSION. Read the "Caution" boxes at this manual page: http://us3.php.net/session_register#AEN116800

      Thanks for the reply. I am a comlete novice with this although I don't mind fiddling around with scripts. If they do what I want them to its pure luck. Are you suggesting I remove the top line of the code I posted i.e.

      if(!session_is_registered('defaultseasonid_tplss') || !session_is_registered('defaultmatchtypeid_tplss') || !session_is_registered('defaultlanguage_tplss'))

      Thanks again

        Hi again, I've removed the following from matches.php and index.php:

        if(!session_is_registered('defaultseasonid_tplss') || !session_is_registered('defaultmatchtypeid_tplss') || !session_is_registered('defaultlanguage_tplss'))

        and

        else
        {
        $defaultseasonid = $SESSION['defaultseasonid_tplss'];
        $defaultmatchtypeid = $
        SESSION['defaultmatchtypeid_tplss'];
        $defaultlanguage = $_SESSION['defaultlanguage_tplss'];
        }

        leaving

        {
        $SESSION['defaultseasonid_tplss'] = $pdata['DefaultSeasonID'];
        $
        SESSION['defaultmatchtypeid_tplss'] = $pdata['DefaultMatchTypeID'];
        $SESSION['defaultlanguage_tplss'] = $pdata['DefaultLanguage'];
        $defaultseasonid = $
        SESSION['defaultseasonid_tplss'];
        $defaultmatchtypeid = $SESSION['defaultmatchtypeid_tplss'];
        $defaultlanguage = $
        SESSION['defaultlanguage_tplss'];
        }

        and the scripts seem to be working. I don't know hat the bit of code I've removed does but will the programme work okay without the code I've removed.

        Thanks

          It should be something like this:

          // Check if session values are available for use
          if ((!isSet($_SESSION['defaultseasonid_tplss']))    || 
              (!isSet($_SESSION['defaultmatchtypeid_tplss'])) || 
              (!isSet($_SESSION['defaultlanguage_tplss'])))    {
          
          // Session values are not available so set them to their defaults
          $_SESSION['defaultseasonid_tplss'] = $pdata['DefaultSeasonID'];
          $_SESSION['defaultmatchtypeid_tplss'] = $pdata['DefaultMatchTypeID'];
          $_SESSION['defaultlanguage_tplss'] = $pdata['DefaultLanguage'];
          }
          
          // When sessions are available these will get assigned values from the session,
          // or they will be assigned the default values (from 'if' statement above)
          $defaultseasonid = $_SESSION['defaultseasonid_tplss'];
          $defaultmatchtypeid = $_SESSION['defaultmatchtypeid_tplss'];
          $defaultlanguage = $_SESSION['defaultlanguage_tplss'];
          

            Hi thanks again, i've tried the script, its gives me the following error:

            unexpected '{'

            in relation to this line:

            (!isSet($_SESSION['defaultlanguage_tplss'])) {

            I've tried messing around but can't get it to work

              Happy Anorak wrote:

              Hi thanks again, i've tried the script, its gives me the following error:

              unexpected '{'

              in relation to this line:

              (!isSet($_SESSION['defaultlanguage_tplss'])) {

              I've tried messing around but can't get it to work

              I edited my previous post because there's a missing ')'.

              So before the '{' add another ')', like so:

              (!isSet($_SESSION['defaultlanguage_tplss']))) {

              FYI: Parse Errors are caused by human error. Check on the line of the error, but usually one to many lines before it, for missing closing tags (i.e. ", ), }, ;, etc.).

              Here's a list of what those PHP tokens seen in error messages mean:
              http://us2.php.net/manual/en/tokens.php#tokens

                Hi thanks very much. I've amended the script and it seems to work fine.

                Thanks again 🙂

                  Hi again, the default display is still playing up. I have two other databases set up for two other club sides running the same set of scripts. Its strange but when the other two databases display correctly this one doesn't. When this one works the others don't ! :bemused:

                    Write a Reply...