Hi guys... I'm fairly new to PHP but do have experience with other languages.
Having an issue with sharing variables between multiple PHP scripts on the same page. Here is the deal:
The page in question is called by another page, which then passes a variable in the URL string, ie: www.nnnnn.com?team=HockeyTeam (HockeyTeam being BostonBruins for example)
Once the new page opens up, the variable is retrieved by the following script which has been placed right at the start of the page.
php?>
session_start();
GetTeamName();
$_SESSION['ReceivedTeamName'] = $TeamToSee;
$NameOfTeam = $TeamToSee;
$NameOfTeam = str_replace("_"," ",$NameOfTeam);
$NameOfTeam = str_replace("*","'",$NameOfTeam);
echo "<h1><center>Current Team Roster for</center></h1>";
echo "<h1><center>". $NameOfTeam."</center></h1>";
function GetTeamName() {
global $TeamToSee;
$TeamToSee = $_GET["team"];
}
?>
Further down the page another php script kicks in and tries to retrieve $NameOfTeam , which is a modfied $TeamToSee variable. This seems to work but it's a hit and miss. It almost seems like I can only call it once and every subsequent call returns a null. I eventually got it working through some jiggery pokery magic, which I don't really like because it doesn't seem to make sense.
My other issue is the ReceivedTeamName variable, which is has the same value as what was passed to this page by a previous one. I cannot for life pass it to the other script at all. I tried all sorts of things and eventually ended up with $_SESSION (as per above) which still doesn't work. Funny thing here is that if I was to replace
$_SESSION['ReceivedTeamName'] = $TeamToSee;
with
$_SESSION['ReceivedTeamName'] = 'Hockey Team';
then the other php script sees this variable having 'Hockey Team' as its value.
It almost seems that $TeamToSee variable passes its value to $NameOfTeam and then blanks out.
Any help would be greatly appreciated guys. Please remember, I'm new at this.... :)
thanks