tags:

views:

70

answers:

3

So This part of my code:

print_r($_SESSION['T']);
$T = array_values($data2);
print_r($_SESSION['T']);

Outputs this:

Array ( [0] => NZL ) Array ( [0] => ENG [1] => NZL ) 

That line is the first time $T is declared. As far as I can tell there should be NO reason for $_SESSION['T'] to gain an entry and its definitely causing me problems.
Might be good to note that after that array_values call, the var $T looks like:

Array ( [0] => ENG [1] => NZL ) 

Which is what the second print of $_SESSION['T'] is displaying.

Let me know if you can think of any reason this might be happening, thanks

+3  A: 

Looks like you might have Register Globals turned on.

if (ini_get('register_globals')) {
    die("Register Globals is ON - This is BAD");
}
else  {
    die("Register Globals is OFF - This is GOOD");
}

The idea was that - with register globals - you could use a variable $T as a shorthand for $_GLOBALS['T']... or $_GET['T'] or $_POST['T'] or (of course) $_SESSION['T'].

If it sounds like a bad idea, that's because it is (was) and has now been so aggressively discouraged that it is deprecated and usually off by default.

LeguRi
+1  A: 

This is a known bug/side-effect. See this question for details. It should be sortable by setting register_globals to off.

Pekka
+1  A: 

This is probably caused because you have register_globals set to on (Which is absolutely terrible). (See http://www.php.net/manual/en/security.globals.php)

You should disable register globals so that the SESSION/POST/GET/REQUEST/COOKIE variables do not interfere.

webdestroya