View Full Version : function variable help

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.


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;


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.

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?