Try like this in case id is not INT, and its better to pass as function param rather then $this->uri->segment(2)
public function vote_now($id = '') {
$id = (int) $id;
if ($id > 0) {
$q = $this->db->select('IP')
->from('banned_ip')
->where('entry', $id)
->where('IP', $this->input->ip_address())
->get();
if ($q->num_rows() > 0) {
echo 'Already Voted.';
} else {
$qe = $this->db->query("SELECT * FROM entries WHERE ID='$id' LIMIT 1");
$r = $qe->row_array();
$insert_data_votes = array(
'votes' => $r['votes'] + 1,
);
$this->db->where('ID', $id)->update('entries', $insert_data_votes);
$insert_data = array(
'IP' => $this->input->ip_address(),
'entry' => $id,
);
$this->db->insert('banned_ip', $insert_data);
redirect('foto/' . $id, 'refresh');
}
}
}