Perad Posted March 14, 2008 Share Posted March 14, 2008 $poll = $_GET['poll']; $user_id = $_GET['user']; if (is_int($poll)) { $poll = 13 The if code does not work. If I change the code to (is_int(13)) Then it works.. Any ideas why this is? Quote Link to comment Share on other sites More sharing options...
micah1701 Posted March 14, 2008 Share Posted March 14, 2008 try using is_numeric instead. sometimes the php considers your number a string and not an integer, depending on how it was assigned to the variable Quote Link to comment Share on other sites More sharing options...
accident Posted March 14, 2008 Share Posted March 14, 2008 I would either type cast it with (int) or use ctype_digit if validating user input personally Quote Link to comment Share on other sites More sharing options...
thebadbad Posted March 14, 2008 Share Posted March 14, 2008 GET and POST values are always strings, therefore is_int fails. Also, is_numeric will accept scientific and hexadecimal notation. If you only want to allow integers, use ctype_digit. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.