我收到这样的错误
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘Satuan, `Satuan`) VALUES (‘KMJ001’, ‘KKMJ005’, ‘asdf asdf’, ‘123123’, ‘kg’)’ at line 1
INSERT INTO `ms_material_jasa` (`Kode_Material_Jasa`, `Kode_Kategori_Material_Jasa`, `Nama_Jenis_Material_Jasa`, `Harga` Satuan, `Satuan`) VALUES (‘KMJ001’, ‘KKMJ005’, ‘asdf asdf’, ‘123123’, ‘kg’)
它指的是我的活动记录模型
function create($kmj,$kkmj,$njmj,$hs,$s)
{
$data=array('Kode_Material_Jasa' => $kmj, 'Kode_Kategori_Material_Jasa' => $kkmj, 'Nama_Jenis_Material_Jasa' => $njmj, 'Harga Satuan' => $hs, 'Satuan' => $s);
$this->db->insert('ms_material_jasa',$data);
}
这是我的控制器
function tambah()
{
$data['kmj'] = $this->input->post('kmj');
$data['kkmj'] = $this->input->post('kkmj');
$data['njmj'] = $this->input->post('njmj');
$data['hs'] = $this->input->post('hs');
$data['s'] = $this->input->post('s');
$data['title'] = 'QB Tambah Material / Jasa';
$data['pesan'] = $data['kmj'].' berhasil ditambahkan ! ';
$this->form_validation->set_rules('kmj','Kode Material / Jasa','trim|required|min_length[2]|max_length[20]|xss_clean');
$this->form_validation->set_rules('kkmj','Kode Kategori Material / Jasa','trim|required|min_length[2]|max_length[20]|xss_clean');
$this->form_validation->set_rules('njmj','Nama Jenis Material / Jasa','trim|required|min_length[2]|max_length[20]|xss_clean');
$this->form_validation->set_rules('hs','Harga Satuan','trim|required|min_length[2]|numeric|max_length[20]|xss_clean');
$this->form_validation->set_rules('s','Satuan','xss_clean');
if($this->form_validation->run() == false)
{
$lastval = $this->m_admin->getlastval('KMJ','ms_material_jasa','kode_material_jasa');
$data['nextval'] = $this->m_admin->gencode('KMJ',3,$lastval);
$this->load->view('head',$data);
$this->load->view('content/add_material_jasa',$data);
}
else
{
$this->m_materialjasa->create($data['kmj'],$data['kkmj'],$data['njmj'],$data['hs'],$data['s']);
$data['kirim'] = $this->m_materialjasa->read();
$this->load->view('head',$data);
$this->load->view('v/vkategorimaterial',$data);
}
}
看起来像下面的查询
INSERT INTO `ms_material_jasa` (`Kode_Material_Jasa`, `Kode_Kategori_Material_Jasa`, `Nama_Jenis_Material_Jasa`, `Harga` Satuan, `Satuan`) VALUES (‘KMJ001’, ‘KKMJ005’, ‘asdf asdf’, ‘123123’, ‘kg’)
是正确的,这是ms_material_jasa
表格。看起来该条目不会破坏数据库上的数据 type.length 。我不知道出了什么问题,我该如何解决?