Welcome Guest, Not a member yet? Register   Sign In
is_int issue?
#2

[eluser]CroNiX[/eluser]
$this->uri->segment() returns a string, or boolean FALSE if the segment doesn't exist. So, it will never be an int unless you cast it like $gallery_id = (int)$gallery_id; If you do that though, it will never be boolean FALSE, it will be 0 in that case.
Code:
else if($action == 'edit')
{
  $gallery_id = $this->uri->segment(5, FALSE);
  
  //if the segment exists, cast it as an int or else trigger 404
  if ($gallery_id !== FALSE)
  {
    $gallery_id = (int)$gallery_id;
  }
  else
  {
    show_404();
  }              
}
You can check for yourself by running var_dump($gallery_id); right after you get it from the segment before doing anything else.


Messages In This Thread
is_int issue? - by El Forum - 02-22-2012, 12:02 PM
is_int issue? - by El Forum - 02-22-2012, 01:36 PM



Theme © iAndrew 2016 - Forum software by © MyBB