codeigniter - having issues with Error Number: 1064 -
any time try access page created says:
error number: 1064
you have error in sql syntax; check manual corresponds mysql server version right syntax use near '' @ line 3
select * (`_db_tb_article`) `article_id` =
filename:
c:\xampp\htdocs\gtech\__ghtec__$y$tem__core\database\db_driver.php
line number:
330
this model
<?php class article_model extends ci_model { function add() { $this->db->insert('article',$_post); if($this->db->_error_number()){ return $this->db->_error_number(); } } function update($article_id, $data_fields = null){ if($data_fields == null){ $this->db->where("article_id =".$article_id); $this->db->update('article',$_post); }else{ $this->db->where("article_id =".$article_id); $this->db->update('article',$data_fields); } $is_error = $this->db->_error_number(); if($is_error){ echo $is_error; } return true; } function delete($id){ $this->db->where("article_id =".$id); return $this->db->delete('article'); } //return article id function get_article($id){ $this->db->where("article_id =".$id); $query = $this->db->get('article'); if ($query->num_rows() > 0){ return $query->row_array(); } else { echo $this->db->_error_message(); return false; } } //return available article in table function get_article_all(){ $query = $this->db->get('article'); if ($query->num_rows() > 0){ foreach($query->result() $row){ $result[] = $row; } return $result; } } }
i have checked line 330 , can't seem find way solve problem... need help
in statement
function update
$this->db->where("article_id =".$article_id);
should be
$this->db->where('article_id', $article_id);
function get_article
$this->db->where("article_id =".$id);
should be
$this->db->where('article_id', $id);
function delete
$this->db->where("article_id =".$id);
should be
$this->db->where('article_id', $id);
Comments
Post a Comment