api中的条件返回数据库错误

I'm trying to edit in api service which i want to make it didn't show the last news when the message staute is blocked , and only showing them when the news message is active so here's the function doing that but I'm getting an error ( Database error )

    public function getlatest($select_values = "*", $table_name, $join_on = "", $language_id) {
    $join_table = "language_" . $table_name;
    $result = array();
    $this->db->select($select_values);
    $this->db->from($table_name);
    if ($table_name != "latestnews") {
        $this->db->where($table_name . ".featuredstatus", "Yes");

    }
    $this->db->join($join_table, $table_name . "." . $join_on . "=" . $join_table . "." . $join_on, "left");
    $this->db->where($join_table . ".languageid", $language_id);
     $this->db->where($table_name . ".latestnewsstatus", "Active");
   $this->db->limit("2");
    $result = $this->db->get()->result_array();
    return $result;
}

It was working fine without that line :

     $this->db->where($table_name . ".latestnewsstatus", "Active");

Which i have added It to showing only the messages with active statue . so why I'm getting this error ?