Jump to content

[SOLVED] Problem with number verification


Porl123

Recommended Posts

I made a function which makes sure all numbers entered only contain the characters 0-9 but for some reason if you enter random numbers it returns false

 

function validno($var) {

if(!is_numeric($var)) {

$ret = 0;

} elseif($var < 0) {

$ret = 0;

} elseif(!preg_match('/^[0-9]+$/', $var)) {

$ret = 0;

} else {

$ret = 1;

}

return $ret;

}

 

It returns false if you enter 12000000000, 14000000000, 17000000000 that I'm aware of. Probably more but I'm not sure. Any see the problem? Thanks

Link to comment
https://forums.phpfreaks.com/topic/177310-solved-problem-with-number-verification/
Share on other sites

I just realised it wasn't in that function :P it was in the script. I'm not sure why but 12000000000 was converted to 1.2E+10 and when I used intval to get the value I saw intval has a limit of 2147483647

 

If anyone knows any other functions I'd really appreciate you helping me

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.