首页 > 解决方案 > 查询错误:列不能为空 - 查询无效

问题描述

我在方法 get 中使用代码 php 在“tr_no_hp”列中发布,例如

$nomorhp = $this->input->get('nomor_hp');

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

这是我的控制器代码

$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();

我得到了这个错误代码

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

谢谢

标签: phpcodeigniter

解决方案


在 phpmyadmin 中分配'tr_no_hp'列的默认值NULL

在此处输入图像描述


推荐阅读