为什么我的代码出现此错误,点击按钮提交后点击链接搜索:
我使用codeigniter。
An error has occured:
[object Object]
error
这是我的Tour_foreign-> CI_Controller:
function search_customer(){
$customer_number = $this->input->post('customer_number');
$query = $this->db->get_where('customer', array('customer_number' => $customer_number));
if($query->num_rows()==0){
echo '0';
}else{
$data = array();
foreach ($query->result() as $row)
{
$data[] = $row;
}
echo json_encode($data);
}
}
function insert_customers(){
$customer_number = "";
for($i = 0; $i < 10; $i++)
$customer_number .= mt_rand(0, 9);
/*////////////////////////////////////*/
$jdate = jgmdate("j F Y");
/*////////////////////////////////////*/
$useradmin = $this->session->userdata('login');
$query = $this->db->get_where('login', array('useradmin' => $useradmin))->row();
$nameadmin = $query->nameadmin;
$lastnameadmin = $query->lastnameadmin;
/*////////////////////////////////////*/
$data = array (
'customer_number' => $customer_number,
'name' => $this->input->post('name'),
'name_en' => $this->input->post('name_en'),
'father_name' => $this->input->post('father_name'),
'number_birth_certificate' => $this->input->post('number_birth_certificate'),
'national_number' => $this->input->post('national_number'),
'passport_number' => $this->input->post('passport_number'),
'term_passport' => $this->input->post('term_passport'),
'date_of_birth' => $this->input->post('date_of_birth') ,
'phone' => $this->input->post('phone'),
'mobile' => $this->input->post('mobile'),
'address' => $this->input->post('address'),
'nationality' => $this->input->post('nationality'),
'accommodation' => $this->input->post('accommodation'),
'education' => $this->input->post('education'),
'zip_code' => $this->input->post('zip_code'),
'marital_status' => $this->input->post('marital_status'),
'bank_name' => $this->input->post('bank_name'),
'branch_name' => $this->input->post('branch_name'),
'card_number' => $this->input->post('card_number'),
'account_number' => $this->input->post('account_number'),
'zip_code' => $this->input->post('zip_code'),
'job' => $this->input->post('job'),
'date_submit' => $jdate,
'useradmin_submit' => $nameadmin.' '.$lastnameadmin ,
);
//if(!empty($data)){
$this->db->insert('customer', $data);
//}
}
答案 0 :(得分:0)
当我尝试使用此脚本时,我在firebug的控制台中看到以下错误: NetworkError:500内部服务器错误
这就是错误出现的原因。修复服务器部分。 尝试清除search_customer()函数中的所有代码,看看它是否运行。如果这个方法永远不会被执行,那么问题出在你的框架之外?
然后,逐行查看服务器上发生的情况。它可能是查询的问题?但通常错误500是当你遇到mod_rewrite问题时。