`$count` is no longer descriptive here. `$data_exists` instead? You should also run `$this->db->sql_freeresult($result)` after the query.