Postingan lainnya
Konversi array to string codeigniter
ini gimana ya? mau insert data muncul gini
A PHP Error was encountered
Severity: Notice
Message: Array to string conversion
Filename: models/Model_data.php
Line Number: 13
Backtrace:
File: C:\xampp\htdocs\reminder_pkb\application\models\Model_data.php
Line: 13
Function: _error_handler
File: C:\xampp\htdocs\reminder_pkb\application\controllers\Data.php
Line: 17
Function: simpan
File: C:\xampp\htdocs\reminder_pkb\index.php
Line: 315
Function: require_once
Model_datanya gini
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Model_data extends CI_Model {
public function load_agenda(){
$sql = $this->db->query("SELECT * FROM konten_agenda ORDER BY ID_Konten_Agenda desc");
return $sql->result_array();
}
public function simpan($post){
$nama = $this->db->$post['nama'];
$tanggal = $this->db->$post['tanggal'];
$tempat = $this->db->$post['tempat'];
$sql = $this->db->query("INSERT INTO konten_agenda VALUES (NULL, $nama, $tanggal, $tempat)");
if($sql)
return true;
return false;
}
public function hapus($id){
$this->db->where('konten_agenda.ID_Konten_Agenda', $id);
return $this->db->delete('konten_agenda');
}
}
3 Jawaban:
$nama = $this->db->$post['nama'];
harusnya
$nama = $post['nama'];
ok terima kasih mastah, udah engga eror lgi, tpi skrng sqlnya eror
<pre> Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'Sehat Bersama Khofifah, 2019-02-19, Ketintang)' at line 1
INSERT INTO konten_agenda VALUES (NULL, Jalan Sehat Bersama Khofifah, 2019-02-19, Ketintang) </pre>
mohon pencerahannya mastah
Tanggapan
buat thread baru aja
INSERT INTO person (first_name, last_name) VALUES ('John', 'Doe');
harusnya kaya gini mas broh.
atau nilai nya ada yang NULL
Tanggapan
ada nilai nullnya, yang ID, di phpmyadmin IDnya auto increment