Postingan lainnya
Error a database oncurred
ini file Controler
<?php
class Mahasiswa extends CI_Controller
{
public function index()
{
$data['mahasiswa'] = $this->mahasiswa_model->tampil_data('mahasiswa')->result();
$this->load->view('templates_administrator/header');
$this->load->view('templates_administrator/sidebar');
$this->load->view('administrator/mahasiswa', $data);
$this->load->view('templates_administrator/footer');
}
public function detail($id)
{
$data['detail'] = $this->mahasiswa_model->ambil_id_mahasiswa($id);
$this->load->view('templates_administrator/header');
$this->load->view('templates_administrator/sidebar');
$this->load->view('administrator/mahasiswa_detail', $data);
$this->load->view('templates_administrator/footer');
}
public function tambah_mahasiswa()
{
$data['prodi'] = $this->mahasiswa_model->tampil_data('mahasiswa')->result();
$this->load->view('templates_administrator/header');
$this->load->view('templates_administrator/sidebar');
$this->load->view('administrator/mahasiswa_form', $data);
$this->load->view('templates_administrator/footer');
}
public function tambah_mahasiswa_aksi()
{
$this->_rules();
if ($this->form_validation->run() == FALSE) {
$this->tambah_mahasiswa();
} else {
$nim = $this->input->post('nim');
$nama_lengkap = $this->input->post('nama_lengkap');
$alamat = $this->input->post('alamat');
$email = $this->input->post('email');
$telepon = $this->input->post('telepon');
$tempat_lahir = $this->input->post('tempat_lahir');
$tanggal_lahir = $this->input->post('tanggal_lahir');
$jenis_kelamin = $this->input->post('jenis_kelamin');
$nama_prodi = $this->input->post('nama_prodi');
$photo = $_FILES['photo'];
if ($photo = '') {
} else {
$config['upload_path'] = './assets/uploads';
$config['allowed_types'] = 'jpg|png|gift|tift';
$this->load->library('upload', $config);
if (!$this->upload->do_upload('photo')) {
echo "Gagal Upload";
die();
} else {
$photo = $this->upload->data('files_name');
}
}
$data = array(
'nim' => $nim,
'nama_lengkap' => $nama_lengkap,
'alamat' => $alamat,
'email' => $email,
'telepon' => $telepon,
'tempat_lahir' => $tempat_lahir,
'tanggal_lahir' => $tanggal_lahir,
'jenis_kelamin' => $jenis_kelamin,
'nama_prodi' => $nama_prodi,
'photo' => $photo
);
$this->mahasiswa_model->insert_data($data, 'mahasiswa');
$this->session->set_flashdata('pesan', '<div class="alert alert-success alert-dismissible fade show" role="alert">
Data Mahasiswa Berhasil ditambahkan!
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>');
redirect('administrator/mahasiswa');
}
}
public function _rules()
{
$this->form_validation->set_rules('nim', 'Nim', 'required', ['required' => 'Nim wajib diisi!']);
$this->form_validation->set_rules('nama_lengkap', 'Nama Lengkap', 'required', ['required' => 'Nama Lengkap wajib diisi!']);
$this->form_validation->set_rules('alamat', 'Alamat', 'required', ['required' => 'Alamat wajib diisi!']);
$this->form_validation->set_rules('email', 'Email', 'required', ['required' => 'Email wajib diisi!']);
$this->form_validation->set_rules('telepon', 'Telepon', 'required', ['required' => 'Telepon wajib diisi!']);
$this->form_validation->set_rules('tempat_lahir', 'Tempat Lahir', 'required', ['required' => 'Tempat lahir wajib diisi!']);
$this->form_validation->set_rules('tanggal_lahir', 'Tanggal Lahir', 'required', ['required' => 'Tanggal Lahir wajib diisi!']);
$this->form_validation->set_rules('jenis_kelamin', 'Jenis Kelamin', 'required', ['required' => 'Jenis Kelamin wajib diisi!']);
$this->form_validation->set_rules('nama_prodi', 'Nama Prodi', 'required', ['required' => 'Nama Prodi wajib diisi!']);
}
}
error number : 1048 Error Number: 1048
Column 'photo' cannot be null
INSERT INTO `mahasiswa` (`nim`, `nama_lengkap`, `alamat`, `email`, `telepon`, `tempat_lahir`, `tanggal_lahir`, `jenis_kelamin`, `nama_prodi`, `photo`) VALUES ('80401732', 'Ikhsan Madani', 'Bogor Utara Selatan Barat', 'mitradarmaz@gmail.com', '08556789765', 'Nias', '1988-11-22', 'Laki-laki', 'Sistem Informasi', NULL)
Filename: C:/xampp/htdocs/sisfo_akademik/system/database/DB_driver.php
Line Number: 691
0
1 Jawaban:
Bisa diperjelas lagi masalah nya gan? Kalo bisa sertakan screenshot sama scriptnya yaa
0