Home > database >  A Database Error Occurred Error Number: 1048 Column 'ket' cannot be null
A Database Error Occurred Error Number: 1048 Column 'ket' cannot be null

Time:07-30

I got an error that says:

Error Number: 1048 Column 'ket' cannot be null

INSERT INTO tb_uploadv (ket, tgl, video) VALUES (NULL, NULL, NULL)

Filename: C:/xamppV5/htdocs/sicams/system/database/DB_driver.php

Line Number: 691

can all master help me pls.

my controller: controllers/Uploadv.php

<?php
class Uploadv extends CI_Controller{
    public function index(){

    $data['uploadv'] = $this->m_uploadv->tampil_data()->
        result();

        $this->load->view('templates/header');
        $this->load->view('templates/sidebarupv');
        $this->load->view('uploadv', $data);
        $this->load->view('templates/footer');
    }

    public function tambah_aksi()
    {
        $data = [
        'ket'           => $this->input->post('ket'),
        'tgl'           => $this->input->post('tgl'),
        'video'         => $this->input->post('video'),
        
        ];

        $this->m_uploadv->input_data($data, 'tb_uploadv');
        redirect('uploadv/index');
    }
}

?>

my view: views/uploadv.php

 <div >
    <section >
        <h5>
            Data Rekaman
            <small>Silahkan Upload Data Rekaman</small>
        </h5>
    </section>

    <section >
        <button  data-toggle="modal" data-target="#exampleModal"><i ></i>Tambah Data</button>
        <table >
            <tr>
                <th>No</th>
                <th>Keterangan</th>
                <th>Tanggal Rekaman</th>
                <th>File Rekaman</th>
            </tr>

            <?php 

                $no = 1;
                foreach ($uploadv as $upv) : ?>
                    <tr>
                        <td><?php echo $no   ?></td>
                        <td><?php echo $upv->ket ?></td>
                        <td><?php echo $upv->tgl ?></td>
                        <td><?php echo $upv->video ?></td>
                    </tr>

             <?php endforeach; ?>
        </table>
    </section>


<!-- Modal -->
<div  id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div  role="document">
    <div >
      <div >
        <h5  id="exampleModalLabel">FORM UPLOAD REKAMAN</h5>
        <button type="button"  data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div >
        <form method="post" action="<?php echo base_url().'uploadv/tambah_aksi';?>">

            <div >
                <label>Keterangan</label>
                <input type="text" name="keterangan" >
            </div>

            <div >
                <label>Tanggal Rekaman</label>
                <input type="date" name="tanggal_rekam" >
            </div>

            <div >
                <label>File Rekaman</label>
                <input type="text" name="bukti" >
            </div>

                <button type="reset" 
                 data-dismiss="modal">Batal</button>
        <button type="submit" >Simpan</button>
        </form>
      </div>
   
    </div>
  </div>
</div>
</div>

My Model: models/M_uploadv.php

    <?php 

class M_uploadv extends CI_Model {

    public function tampil_data() 
    {
        return $this->db->get('tb_uploadv');
    }   

    public function input_data($data)
    {
        $this->db->insert('tb_uploadv', $data);
    }
}

CodePudding user response:

You're submitting input field with another names, you input names should be match.

Try this code.

public function tambah_aksi()
{
    $data = [
    'ket'       => $this->input->post('keterangan'),
    'tgl'       => $this->input->post('tanggal_rekam'),
    'video'     => $this->input->post('bukti'),
    ];

    $this->m_uploadv->input_data($data, 'tb_uploadv');
    redirect('uploadv/index');
}
  • Related