whats wrong with this?

#1
[eluser]dadamssg[/eluser]
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?
Code:
if (isset($id) && is_numeric($id))
        {
              $yes = $this->Eventmodel->get_exists($id);
              if($yes !== 1){redirect('mains');}
            }
            else
            {
              redirect('mains');
            }

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

#3
[eluser]dadamssg[/eluser]
yeah heres the route

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

i just don't want sql injections from my segments

#4
[eluser]Udi[/eluser]
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.

#5
[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.

#6
[eluser]dadamssg[/eluser]
oh ok. thanks man


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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