Postingan lainnya
Call to undefined function library()
Saya mempunyai masalah ketika menyimpan profil saya. Problemnya adalah sebagai berikut:
An uncaught Exception was encountered
Type: Error
Message: Call to undefined function library()
Filename: C:\xampp\htdocs\sisko\application\controllers\profile.php
Line Number: 39
Backtrace:
File: C:\xampp\htdocs\sisko\index.php
Line: 315
Function: require_once
Berikut saya sertakan code controller/profile.php
<?php
class Profile extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->model('M_profile');
}
public function index()
{
$data = array('data_profile' => $this->M_profile->ambil_profile()->result_array(),);
$this->load->view('template/header');
$this->load->view('template/sidebar');
$this->load->view('dashboard/profile', $data);
$this->load->view('template/footer');
}
function tambah_profile(){
$this->load->view('template/header');
$this->load->view('template/sidebar');
$this->load->view('dashboard/tambah_profile');
$this->load->view('template/footer');
}
function simpan_profile(){
$id_profile = '';
$judul = $this->input->post('judul');
$isi = $this->input->post('isi');
$config['max_size']=2048;
$config['allowed_types']="jpg|jpeg|png";
$config['remove_spaces']=TRUE;
$config['overwrite']=TRUE;
$config['upload_path']=FCPATH.'tentang';
$this->load-library('upload');
$this->upload->initialize($config);
$data = $this->upload->do_upload('gambar');
$data_image = $this->upload->data('file_name');
$location = 'tentang/';
$pict = $location-$data_image;
$data = array(
'id_profile'=>$id_profile,
'nama'=>$judul,
'isi'=>$isi,
'gambar'=>$pict
);
$this->M_profile->simpan('profile', $data);
$this->session->set_flashdata('sukses', "div class='alert alert-success alert-block'> <a class='close' data-dismis='alert' href='#'>x</a><h4 class='alert-heading'>Sukses!</h4>Data berhasil disimpan!</div>");
redirect('profile');
}
}
?>
Bagaimana cara memperbaikinya? Terima kasih sebelumnya.
1 Jawaban:
<div>Coba ganti baris ini : </div><pre>$this->load-library('upload');</pre><div><br>Menjadi ini :</div><pre>$this->load->library('upload');</pre><div><br>Kemudian baris ini juga :</div><pre>$pict = $location-$data_image;</pre><div>Diganti menjadi ini :</div><pre>$pict = $location . $data_image; //digabungkan (concat)</pre><div><br>Kesalahannya ada pada penulisan chain methodi, harus nya kaya gini : " methodA->methodB(); <br><br></div><div>Semoga membantu!</div>
Tanggapan
Untuk yang $pict = $location-$data_image sepertinya memang bukan panah, karena $location bukan object/class melainkan string biasa. Cuma gak tau maksud string dikurangi tersebut.
ohh iya betul, itu kayanya mau di concat kali ya?