php - call the ' id ' of the mysql database with varchar format but Unknown column 'GE' in 'where clause' -
this question has answer here:
i tried call data 'id' format id example id = ge-dis-001 join table codeigniter , result of "unknown column ' ge ' in 'where clause ' what's wrong ??
controller :
public function detail(){ $id = $this->uri->segment(4); $detail = $this->mcrud->get_detail($id); $data = array( 'detail'=>$detail, 'lihat' =>$this->mcrud->lihat_komentar($id), 'isi' =>'instrument/read_views'); $this->load->view('layout/wrapper', $data); }
model :
public function get_detail($id){ $sql = "select * tbdetail join tbkalibrasi on tbkalibrasi.id = tbdetail.id join tbsupplier on tbsupplier.namasupplier = tbdetail.namasupplier tbdetail.id = {$id} "; return $this->db->query($sql)->result_array(); }
it seems $id
variable contains string spaces, getting error. change to
public function get_detail($id){ $sql = "select * tbdetail join tbkalibrasi on tbkalibrasi.id = tbdetail.id join tbsupplier on tbsupplier.namasupplier = tbdetail.namasupplier tbdetail.id = '$id' "; return $this->db->query($sql)->result_array(); }
Comments
Post a Comment