Reputation: 11
I'm trying to display zipcode which only logged in user's area.
To get user's area, get_zipcode()
calls get_area_name()
.
But, there is 500 error
if I get value from get_area_name()
;
If I commented out get_area_name()
and put harded coded value $area ="ny"
, it works.
I think there is some issue with get_area_name()
.
table for "area
" is following
CREATE TABLE IF NOT EXISTS `wn_area` (
`area_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`area` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`area_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=165 ;
Function
public function get_zipcode($area_id)
{
$this->db->select("*");
$this->db->from("zipcode");
if ($area_id != "" )
{
$ar_area_ids = array(1,2,3,4,5,6,7,8);
//$area = get_area_name($area_id);
$area = "ny";
if( in_array($area_id, $ar_area_ids) ){
$this->db->like('sido', $area);
}else {
$this->db->like('gugun', $area);
}
}else{
$this->db->like("sido", 'ny');
$this->db->limit("10000");
}
$this->db->order_by("zipcode_id");
$query = $this->db->get();
return ($query->num_rows() > 0) ? $query->result() : FALSE;
}
public function get_area_name($area_id)
{
$this->db->select("*");
$this->db->from("area");
$this->db->where("area_id", $area_id);
$query = $this->db->get();
return $query->row()->area;
}
Upvotes: 0
Views: 45
Reputation: 100175
since its class to call method from another method inside class , you need to use $this
, like, change:
$area = get_area_name($area_id);
to
$area = $this->get_area_name($area_id);
Upvotes: 1