Jump to content

global varable


j4ymf

Recommended Posts

hello folks

 

its been along time since iv'e been on here, but iv'e just start playing with php again and i would like some help please.

 

// *-----------------------------------------------------------*
// * check_team_total()                                        *
// *                                                           *
// * Makes sure that no dreamteam has a value of more than     *
// * £50 million                                               *
// *-----------------------------------------------------------*


function check_team_total($player_1, $player_2, $player_3, $player_4, $player_5, $player_6, $player_7, $player_8, $player_9, $player_10, $player_11) {

include("passwords.inc");

$connection = mysql_connect($host, $user,$password) or die ("Couldn't connect to server.");
$db = mysql_select_db($database, $connection) or die ("Couldn't select database.");

$query  = "SELECT sum(price) 'total' ";
$query .= "FROM dreamteam ";
$query .= "WHERE dreamteam.id ";
$query .= "IN ('$player_1', '$player_2', '$player_3', '$player_4', '$player_5', '$player_6', '$player_7', '$player_8', '$player_9', '$player_10', '$player_11')";
  

$result = mysql_query($query) or die ("<font color='#ffff00' size='4'>Error! checking your team total!    (3)");

$total = mysql_fetch_assoc($result);

if ($total['total'] > 50) { // change to 40 for normal seasons 50 for the world cup
	global $truetotal;
	$truetotal = $total;		
	return False;
} else {
	return True;
}

}

 

i need to be able to use $truetotal as a global so i can pull it in a few places.ive added this but i cant get it to work,

global $truetotal; $truetotal = $total;

 

please could you get me started again

many thanks jason

 

 

Link to comment
https://forums.phpfreaks.com/topic/166450-global-varable/
Share on other sites

hello amtran

 

in the function it it used for adding up the total and checking if its not above 50

 

i would like to be able to use it within the same file just call back the total and use it out side that function

if you get what i mean.

 

jason

Link to comment
https://forums.phpfreaks.com/topic/166450-global-varable/#findComment-877840
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.