if语句从数据库中提取错误数据的问题

时间:2013-12-23 04:31:19

标签: php

我拥有一个锦标赛脚本,我在脚本中内置了一个报告系统。以下是代码。

$this_search=array();

switch($t['bracket_size']) {

case 8:
$games_count=8;
$rounds_count=3;
break;

case 16:
$games_count=16;
$rounds_count=4;
break;

case 32:
$games_count=32;
$rounds_count=5;
break;

case 64:
$games_count=64;
$rounds_count=6;
break;

case 128:
$games_count=128;
$rounds_count=7;
break;

}

for($rounds = $rounds_count; $rounds > 0; $rounds--) 
{
for($games = $games_count; $games > 0; $games--)  
{
    if($b["w_r".$rounds."_s".$games.""]==$my_team_info['team_id']) {
        $this_search['round']=$rounds;    
        $this_search['game']=$games;   
        break; 
    } 
} 
}  

if (
$this_search['round']=='') {$smarty->assign('error', "Sorry, we couldn't find your match. Contact Live Support."); 
}else{

$match_check=d_c("select * from tournaments_reports where tid='$t[id]' and round='$this_search[round]' and game='$this_search[game]'"); 
if ($match_check==0) {} 
    else{
$match_check_info=d("select * from tournaments_reports where tid='$t[id]' and round='$this_search[round]' and game='$this_search[game]'");     
    if ($match_check_info['team_A']==$my_team_info['team_id'] or $match_check_info['team_B']==$my_team_info['team_id']) { 
        $smarty->assign('error', "Sorry, your team has already reported this match. If this is an error, contact live support.");  
    } 

} 
}



if ($_POST[submit])
{
    if ($match_check==0) {$ins=d_i("INSERT INTO `tournaments_reports` (`id`, `tid`, `team_A`, `team_B`, `team_A_report`, `team_B_report`, `team_A_time`, `team_B_time`, `round`, `game`) VALUES ('', '$t[id]', '0', '0', '0', '0', '0', '0', '$this_search[round]', '$this_search[game]')");}   

if ($_POST[report]==1) { 
    // LOSS
    if ($match_check[team_A]==''){   
        $update=d_u("update tournaments_reports set team_A='$my_team_info[team_id]',team_A_report='2',team_A_time='".time()."' where tid='$t[id]' and round='$this_search[round]' and game='$this_search[game]'");  
    }
    elseif ($match_check[team_B]==''){  
        $update=d_u("update tournaments_reports set team_B='$my_team_info[team_id]',team_B_report='2',team_B_time='".time()."' where tid='$t[id]' and round='$this_search[round]' and game='$this_search[game]'");
    } 
} 
elseif ($_POST[report]==2) {
    // WIN
    if ($match_check[team_A]==''){  
        $update=d_u("update tournaments_reports set team_A='$my_team_info[team_id]',team_A_report='1',team_A_time='".time()."' where tid='$t[id]' and round='$this_search[round]' and game='$this_search[game]'"); 
    }
    elseif ($match_check[team_B]==''){ 
        $update=d_u("update tournaments_reports set team_B='$my_team_info[team_id]',team_B_report='1',team_B_time='".time()."' where tid='$t[id]' and round='$this_search[round]' and game='$this_search[game]'");
    }
}

$smarty->assign('success', "Thank you for your report.");
}

代码应该通过括号数据库($b)搜索用户当前所在的回合和游戏。

然后显示代码(未包含)并允许用户报告他们当前所在的回合和游戏的分数。

上面的代码选择了不正确的列来拉取回合和游戏数。

实施例: 我的球队在第一轮比赛2中 我已经晋级第2轮比赛1 当我去报告第2轮比赛1的得分时,我收到一条错误说“你已经报告了第1轮比赛2分”

我现在在第2轮第1场比赛,所以它应该允许我报告该轮和比赛,但事实并非如此。我发现上面的代码需要改变,但我不确切知道需要改变或修改的内容。

0 个答案:

没有答案