...

View Full Version : function variable help



ptmuldoon
03-27-2010, 05:53 PM
I'm trying to pass a variable into a function, yet I keep getting an undefined index error, and unsure what could be wrong?

I'm adding in the first variable at the moment, but it should eventually include the points, kills, wins, and games_played. Yet, just adding the first variable is giving me an error.

snippet...


while ($rank = mysql_fetch_assoc($result2))
{
if($rank['variable'] == 'cust_points'){$row['points'] = $rank['value'];}
if($rank['variable'] == 'cust_players'){$row['kills'] = $rank['value'];}
if($rank['variable'] == 'cust_win'){$row['wins'] = $rank['value'];}
if($rank['variable'] == 'cust_gamesp'){$row['games_played'] = $rank['value'];}

//Get Ranking based on formula
$row['ranking'] = rank_formula($row['points']);
}

//The function
function rank_formula($points){

// Ranking code here
return $rank;

}

MattF
03-27-2010, 05:59 PM
$row['points'] = (($rank['variable'] == 'cust_points') ? $rank['value'] : false);
$row['kills'] = (($rank['variable'] == 'cust_players') ? $rank['value'] : false);
$row['wins'] = (($rank['variable'] == 'cust_win') ? $rank['value'] : false);
$row['games_played'] = (($rank['variable'] == 'cust_gamesp') ? $rank['value'] : false);



Post your full error code and code up if that makes no difference.

DaiLaughing
03-28-2010, 09:13 AM
Are you actually calling the function before it exists or is that just how you have pasted the snippets?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum