0
我已更新所有內容,因爲它已將其更新至最新版本。 但是在我view
文件我收到了一些錯誤,我不明白爲什麼:例如,這在下面:從Codeigniter 1.7.3升級到2.2.0 - 問題
<a href="#" class="teams_button_2">'.($relations[$team->teams_id]?$relation_names[$relations[$team->teams_id]]:'Neutral').'</a>
我得到這個錯誤:
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: relations
Filename: pages/teams.php
Line Number: 48
它完美地工作過,但現在不是了。我還有其他一些類似的東西。什麼可能導致它?
UPDATE:控制器爲:
function view()
{
$data['player'] = $this->user->info($this->user->id());
$data['motors_count'] = $this->user->count_motors($this->user->id());
$data['menu_active']['teams'] = ' active';
$data['teams'] = $this->db->order_by('team_points', 'desc')->get('teams')->result();
if ($this->user->team_id())
{
$relations = $this->db->where('teams_relations_teams_id', $this->user->team_id())->get('teams_relations')->result();
}
$requests = $this->db->where('teams_join_requests_user_id', $this->user->id())->get('teams_join_requests')->result();
$data['requests'] = array();
if ($relations)
foreach ($relations as $relation)
$data['relations'][$relation->teams_relations_second_teams_id] = $relation->teams_relations_type;
if ($requests)
foreach ($requests as $request)
$data['requests'][] = $request->teams_join_requests_teams_id;
$this->load->view('logged/includes/header.php', $data);
$this->load->view('logged/pages/teams.php');
$this->load->view('logged/includes/footer.php');
}
嘗試'var_dump($ data ['relations'])'檢查它是否設置。反正你沒有把'$ data'傳遞給'teams.php view'。 – 2014-09-29 05:10:43