Postingan lainnya
Gan mohon bantuannya. ini kenapa ya kok malah error saat Edit Data
ini keterangan errornya:
A PHP Error was encountered Severity: Warning
Message: getimagesize(C:/xampp/htdocs/web_puskesmas/foto_pegawai): Failed to open stream: Permission denied
Filename: libraries/Image_lib.php
Line Number: 1655
Backtrace:
File: C:\xampp\htdocs\web_puskesmas\application\controllers\Setting.php Line: 80 Function: library
File: C:\xampp\htdocs\web_puskesmas\index.php Line: 315 Function: require_once
A Database Error Occurred Error Number: 1054
Unknown column 'id1' in 'where clause'
UPDATE tlb_setting
SET id
= '1', nama_puskesmas
= 'UPTD Puskesmas Tanjung Satai', email_puskesmas
= 'pusk.tanjungsatai@gmail.com', alamat
= 'Jln. Merdeka Tanjung Satai No. 20 Desa Tanjung Satai kode pos 78858 ', nama_kapus
= NULL WHERE id1
IS NULL
Filename: C:/xampp/htdocs/web_puskesmas/system/database/DB_driver.php
Line Number: 665
ini cotroller ediya
public function edit($id)
{
$this->form_validation->set_rules('nama_puskesmas', 'Nama Puskesmas', 'required');
if ($this->form_validation->run() == TRUE) {
$config['upload_path'] = './foto_pegawai/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['max_size'] = 5000;
$this->upload->initialize($config);
if (! $this->upload->do_upload('fhoto_kapus')) {
$data = array(
'title2' => 'UPTD Puskesmas Tanjung Satai',
'title' => 'Edit Profil Puskesmas',
'error' => $this->upload->display_errors(),
'setting' => $this->m_setting->detail($id),
);
$this->load->view('template/back-end/v_head', $data);
$this->load->view('template/back-end/v_nav', $data);
$this->load->view('template/back-end/sidebar', $data);
$this->load->view('setting/v_edit', $data);
$this->load->view('template/back-end/v_footer');
} else {
// menghapus file Foto Lama
$setting = $this->m_setting->detail($id);
if ($setting->fhoto_kapus != "") {
unlink('./foto_pegawai/' . $setting->fhoto_kapus);
}
// end menghapus foto
$upload_data = array('uploads' => $this->upload->data());
$config['image_library'] = 'gd2';
$config['source_image'] = './foto_pegawai/' . $upload_data['uploads']['file_name'];
$this->load->library('image_lib', $config);
$data = array(
'id' => $id,
'nama_puskesmas' => $this->input->post('nama_puskesmas'),
'email_puskesmas' => $this->input->post('email_puskesmas'),
'alamat' => $this->input->post('alamat'),
'nama_kapus' => $this->input->post('nama_kapus'),
'fhoto_kapus' => $upload_data['uploads']['file_name']
);
$this->m_setting->edit($data);
$this->session->set_flashdata('message', '<div class="alert alert-info alert-dismissible"><b> Data Pegawai Berhasil di Ubah!!! </b> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>', '</div>');
redirect('setting');
}
$upload_data = array('uploads' => $this->upload->data());
$config['image_library'] = 'gd2';
$config['source_image'] = './foto_pegawai/' . $upload_data['uploads']['file_name'];
$this->load->library('image_lib', $config);
$data = array(
'id' => $id,
'nama_puskesmas' => $this->input->post('nama_puskesmas'),
'email_puskesmas' => $this->input->post('email_puskesmas'),
'alamat' => $this->input->post('alamat'),
'nama_kapus' => $this->input->post('nama_kapus')
);
$this->m_setting->edit($data);
$this->session->set_flashdata('message', '<div class="alert alert-info alert-dismissible"><b> Data Pegawai Berhasil di Ubah!!! </b> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>', '</div>');
redirect('setting');
}
$data = array(
'title2' => 'UPTD Puskesmas Tanjung Satai',
'title' => 'Edit Data Profile Puskesmas',
'setting' => $this->m_setting->detail($id),
);
$this->load->view('template/back-end/v_head', $data);
$this->load->view('template/back-end/v_nav', $data);
$this->load->view('template/back-end/sidebar', $data);
$this->load->view('setting/v_edit', $data);
$this->load->view('template/back-end/v_footer');
}
dan juga aku itu mau update. bukan nampilkan data. ini code modelnya nya dibawah.
<?php defined('BASEPATH') or exit('No direct script access allowed'); class M_setting extends CI_Model { public function lists() { $this->db->select('*'); $this->db->from('tlb_setting'); $this->db->order_by('id'); return $this->db->get()->result(); }
public function detail($id)
{
$this->db->select('*');
$this->db->from('tlb_setting');
$this->db->where('id', $id);
return $this->db->get()->row();
}
public function edit($data)
{
$this->db->where('id' . $data['id']);
$this->db->update('tlb_setting', $data);
}
}
ini viewnya :
<section class="content"> <div class="container-fluid"> <div class="card card-primary card-outline"> <div class="row my-5 mr-3 ml-3"> <div class="col-sm-12"> <div class="card"> <div class="card-body"> <?php echo validation_errors('<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>', '</div>');
if (isset($error_upload)) {
echo '<div class="alert alert-success alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>' . $error_upload . '</div>';
}
echo form_open_multipart('setting/edit/' . $setting->id);
?>
<div class="form-group row">
<label class="col-sm-3 col-form-label">Nama Puskesmas</label>
<div class="col-sm-9">
<input class="form-control" type="text" name="nama_puskesmas" value="<?= $setting->nama_puskesmas ?>" placeholder="Nama Puskesmas" required>
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 col-form-label">Email Puskesmas</label>
<div class="col-sm-9">
<input class="form-control" type="text" name="email_puskesmas" value="<?= $setting->email_puskesmas ?>" placeholder="Email Puskesmas" required>
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 col-form-label">Alamat</label>
<div class="col-sm-9">
<textarea class="form-control" type="text" name="alamat" placeholder="Alamat Puskesmas" required><?= $setting->alamat ?></textarea>
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 col-form-label">Kepala Puskesmas</label>
<div class="col-sm-9">
<input class="form-control" type="text" name="kepala_puskesmas" value="<?= $setting->nama_kapus ?>" placeholder="Nama Kepala Puskesmas" required>
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 col-form-label">Fhoto Kepala</label>
<div class="col-sm-9">
<input class="form-control" type="file" name="foto_kapus">
</div>
</div>
<button type="reset" class="btn btn-danger float-right">Reset</button>
<button type="submit" class="btn btn-info float-right mr-2">Simpan</button>
<?php form_close(); ?>
</div>
</div>
</div>
</div>
</div>
</div><!-- /.container-fluid -->
</section>
<!-- /.content -->
Tanggapan
perhatikan "aturan main" saat membuat judul
Belum ada Jawaban. Jadi yang pertama Jawaban
Login untuk ikut Jawaban