whats wrong with this?

Ok so im checking a segment of the uri to make sure its set and numeric and then if it is see if i can find the id number in my db, if not redirect. When i enter an id number thats in the db it works, if its a number thats not in the db it redirects...ok good. BUT if i enter in something like "adsg324" i get a 404 and its not redirecting. whats the deal here?
if (isset($id) && is_numeric($id))
              $yes = $this->Eventmodel->get_exists($id);
              if($yes !== 1){redirect('mains');}

Is there any $route[..] for this part of code?
maybe you added (:num) to the url ($route['some/controller/(:num)'] )

yeah heres the route

$route['events/(:num)'] = 'events/index/$1';

i just don't want sql injections from my segments

The segment didn't passed CI's check, it supposed to be numeric. Consider it that CI already made the is_numeric() check for you - and because its not numeric, you're thrown to 404.

If you want to handle it yourself, change it to (:any) - this way your code will work as you wanted.

[eluser]Craig A Rodway[/eluser]
The route only works for numeric values (the :num part). If you want it to match anything, you have to use :any.

oh ok. thanks man

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.