I am using php and doing sql queries on mysql server. to prevent sql injections, I use mysql_real_escape_string.
I also use (int) for casting numbers as follows:
$desired_age = 12;
$query = "select id from users where (age > ".(int)$desired_age.")";
$result = mysql_query($query);
which work.
But, when the variable contains large numbers, discarding them with an error, since they are more than int.
$user_id = 5633847511239487;
$query = "select age from users where (id = ".(int)$user_id.")";
$result = mysql_query($query);
Is there any other way to cast a large number (e.g. BIGINT), except using mysql_real_escape_string when it comes to preventing sql injection?
source
share