得到了以下函数,并且getteampoints值没有在之前的任何地方声明过。试图遵循其他redececlare错误问题,但没有任何工作。我该如何解决这个问题?致命错误:无法重新声明getteampoints()(先前在
function getTeamPoints($team)
{
$query = mysql_query("SELECT * FROM Team_comp WHERE t_id='$team'");
$team_array = array();
while($a = mysql_fetch_array($query))
{
$team_array = array( 'home_won' => $a['home_win'],
'home_draw' => $a['home_tie'],
'home_lost' => $a['home_lost'],
'away_won' => $a['away_win'],
'away_draw' => $a['away_tie'],
'away_lost' => $a['away_lost'],
'home_games'=> $a['home_games'],
'away_games'=> $a['away_games']);
}
return $team_array;
}
function calculateTeamPoints($team, $type)
{
$teamPts = getTeamPoints($team);
if($type == 'home')
{
$homem = $teamPts['home_games'];
$homew = $teamPts['home_won'];
$percent = ($homew * 100)/$homem;
$remaining = $homem - $homew;
$per = ($remaining * 100)/$homem;
$percent += $per/2;
}
elseif($type == 'away')
{
$homem = $teamPts['away_games'];
$homew = $teamPts['away_won'];
$percent = ($homew * 100)/$homem;
$remaining = $homem - $homew ;
$per = ($remaining * 100)/$homem;
$percent += $per/2;
}
return $percent;
}
function getpercent($hometeamid, $awayteamid)
{
$hometeampts = calculateTeamPoints($hometeamid, 'home');
$awayteampts = calculateTeamPoints($awayteamid, 'away');
$homepercent = floor(($hometeampts - $awayteampts) + 50);
$awaypercent = 100-$homepercent;
}
//demo
getpercent($hometeamid, $awayteamid);
?>
你是否在任何地方包含这个函数文件?如果是,则尝试使用'include_once'。 – Rikesh 2013-04-10 10:40:39
是你在这个脚本中包含任何php脚本。 – Bharanikumar 2013-04-10 11:12:59
当您尝试定义已定义的函数时,通常会发生这种情况。如Rikesh所说,使用include_once。 – 2014-01-25 08:16:17