[英]A Database Error Occurred, Insert data from select option code igniter
I'm add field data from another table, I put the data on select option.我从另一个表中添加字段数据,我将数据放在 select 选项上。 I want save it but database error "nik = null".我想保存它,但数据库错误“nik = null”。
this my error这是我的错误
Column 'nik' cannot be null列 'nik' 不能是 null
INSERT INTO `tbl_kotak` (`nik`, `nama_kotak`, `lokasi`) VALUES (NULL, 'GM 1.3', 'Garment 1')
My Controller我的 Controller
function tambah_aksi()
{
$nik = $this->input->post('nik');
$nama_kotak = $this ->input->post('nama_kotak');
$lokasi = $this->input->post('lokasi');
$data = array (
'nik' => $nik,
'nama_kotak' => $nama_kotak,
'lokasi' => $lokasi
);
$this->m_kotak->input_data($data,'tbl_kotak');
redirect('kotak/index');
}
My Model我的 Model
function get_pic(){
$this->db->order_by('nik','asc');
return $this->db->from('tbl_karyawan')
->get()
->result();
}
Thank You谢谢你
You have to make sure $nik has the valid value try to echo $nik您必须确保 $nik 具有有效值尝试回显 $nik
Please mention your input_data() function code, table structure and also mention view file code for better understanding and result.请提及您的 input_data() function 代码、表结构并提及查看文件代码以便更好地理解和结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.