-1
檢索數據所以我得到錯誤:從MySQL表笨語法錯誤
"Parse error: syntax error, unexpected ';', expecting T_FUNCTION in /application/controllers/c_view_users.php on line 19".
我想不通爲什麼。
這裏是我的控制器:
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
class C_view_users extends CI_controller {
public function __construct(){
parent::__construct();
}
public function index() {
$data = array();
$this->load->model('m_users');
//$this->load->library('table');
$data['result'] = $this->m_users->get_contents();
$this->load->view('view_users', $data);
}
?>
和型號:
<?php
class m_claims extends CI_model {
function __construct() {
parent::__construct();
//Get CI Instance
//$CI = & get_instance();
//$CI->load->model(EASYPHP_CORE_DIR . 'user_auth' , 'user_auth');
//--------------- Table name, caption and controller ---------------
$this->tableName = "users";
$this->caption = "Users";
$this->controllerName = "c_view_users";
$this->recordsPerPage = 25;
//--------------- Pages and function setup ---------------
$this->add = true;
$this->update = true;
$this->view = true;
$this->printView = true;
$this->delete = true;
$this->allowQuickSearch = true;
function get_contents() {
$this->db->select('*');
$this->db->from('scouts');
$query = $this->db->get();
return $result = $query->result();
}
}
}
}?>
,並查看
<table>
<tr>
<th>Content</th>
</tr>
<?php foreach($result as $r): ?>
<tr><?php echo $r->content; ?>
</tr>
<?php endforeach; ?>
</table>
<?php
任何人都可以幫助我們發現在控制器上我的錯誤?我已經嘗試過沒有運氣的消除過程。從這裏,我認爲我的語法看起來不錯。
是你的整個控制器?你在末尾 –
處遺漏了一個右括號'}',顯然我的銳利眼睛並不那麼尖銳。謝謝。 – tkdlax
@tkdlax你已經發布'C_view_users'控制器加載'用戶'模型,並且發佈了'm_claims'模型的代碼。任何關係? –