$post_city = $_POST['city'];
 if (!empty($post_name) && !empty($post_category_type_id)) {
     // Check duplicate data
     $check_cat = $obj_cat_type->isCategoryExist($post_name, $post_category_type_id, $post_city, $user_id);
     if ($check_cat) {
         $check_portal_id = $obj_cat_type->add_portal_category($post_name, $post_category_type_id, $post_city, $post_visiable, $user_id);
         $arr_attr_id = $_POST['attr_id'];
         $arr_attr_val = $_POST['attr_arr'];
         if (!empty($arr_attr_id)) {
             $i = 0;
             $cat_id = $check_portal_id;
             foreach ($arr_attr_id as $key => $value) {
                 if (!empty($arr_attr_val[$i])) {
                     $attr_id = trim($arr_attr_id[$i]);
                     $value = trim($arr_attr_val[$i]);
                     $obj_cat_type->add_user_category_attribute($attr_id, $value, $user_id, $cat_id);
                 }
                 $i++;
             }
         }
         $query = "SELECT * FROM `category_attribute` inner join user_category_attribute on user_category_attribute.attr_id = `category_attribute`.id WHERE cat_id = '" . $check_portal_id . "' and  short_name = 'address' ";
         $sel_result = mysql_fetch_assoc(mysql_query($query));
         /* Update lat lang of category */
         $address_gmap = $sel_result['value'] + $post_city;
         $json = file_get_contents("http://maps.google.com/maps/api/geocode/json?address={$address_gmap}&sensor=false");
         $json = json_decode($json);
         $lat = $json->{'results'}[0]->{'geometry'}->{'location'}->{'lat'};
         $long = $json->{'results'}[0]->{'geometry'}->{'location'}->{'lng'};
         $str = "Update category set lat = '" . $lat . "' , lang = '" . $long . "'  where id = '" . $check_portal_id . "' ";
         $qr = mysql_query($str) or die(mysql_error());
         $error_set = 2;