Php 查询错误:列不能为null-查询无效

Php 查询错误:列不能为null-查询无效,php,codeigniter,Php,Codeigniter,im在“tr\u no\u hp”列中的方法get to post中使用php代码 像 但在我尝试在数据库中插入后,列不能为null。 如何解决这个问题 这是我的控制器代码 $nomorhp = $this->input->get('nomor_hp'); $data = array( 'us_id' => $this->user->us_id, 'sv_id' => $vouch

im在“tr\u no\u hp”列中的方法get to post中使用php代码 像

但在我尝试在数据库中插入后,列不能为null。 如何解决这个问题

这是我的控制器代码

$nomorhp = $this->input->get('nomor_hp');
$data = array(
                    'us_id' => $this->user->us_id,
                    'sv_id' => $voucher->sv_id,
                    'op_id' => $voucher->op_id,
                    'tr_id_plgn' => $nomor,
                    'tr_no_hp' => $nomorhp,


                );

                 $this->db->insert('transaksi', $data);
                 $trx_id =$this->db->insert_id();
我得到了这个eror代码

Query error: Column 'tr_no_hp' cannot be null - Invalid query: INSERT INTO `transaksi`

谢谢

您可以修改表以允许null,但这可能会破坏其他功能,或者设置默认值

例如:

$nomorhp=$this->input->get'nomor_hp'?:;//默认为空字符串
在phpmyadmin中将“tr\u no\u hp”列的默认值指定为NULL


tr_no_hp列是什么类型的?你运行的是什么PHP版本?类型是varchar16,我使用PHP5.6将“tr_no_hp”列的默认值指定为null。你能告诉我更多详细信息吗?在数据库中,将“tr_no_hp”列的默认值指定为null这个“tr_no_hp”列没有默认值null,$nomorhp=$this->input->get'nomor hp';你的这段代码什么也得不到检查发送了什么数据
Query error: Column 'tr_no_hp' cannot be null - Invalid query: INSERT INTO `transaksi`