[eluser]phantom-a[/eluser]
Once again Frank thanks

Your method didn't not work, it threw parse error, unexpected T_VARIABLE on the line
Code:
if (is_int($this->uri->segment(3)) $data['query'] = $this->db->query('SELECT `url` FROM `links` WHERE `id`='.intval($this->uri->segment(3)).''); // only execute if the id is an int
But I didn't know about intval() and I"m always up for learning about the Variable handling Functions. This was great you mentioned this. So Thought of just passing the segment ID into it first then pass it into the query as you see my code,
this which works now 100%.
Code:
$data['title'] = "Redirection..";
$data['heading'] = "Prepare to be redirected to...";
$URL_ID = intval($this->uri->segment(3)); //Turn into integers so no wankers try to pass letters into the query
$data['query'] = $this->db->query('SELECT `url` FROM `links` WHERE `id`='.mysql_real_escape_string($URL_ID).'');
if ($data['query']->num_rows() != 1) { // check if we have exactly one result
header("HTTP/1.0 404 Not Found",true); // wanna be nice
echo '404 not found'; // optional
die; // get outta here
}
$this->db->query('UPDATE `links` SET `hits`=hits+1 WHERE `id`='.mysql_real_escape_string($URL_ID).'');
$this->load->view('redirect_url', $data); // this go to a page there redirects by javascript with the url.
}