EchoFool Posted February 17, 2009 Share Posted February 17, 2009 I keep getting a preg match issue where by even a valid number just sets to 0! This is what i have: <?php $Quantity = strtolower(mysql_real_escape_string(stripslashes($_POST['Move2']))); If(!(preg_match('~^\d+$~', $Quantity))){ $Quantity= 0; } Echo $Quantity; ?> I inputted one and it still comes out as 0 every time.. why is this? Link to comment https://forums.phpfreaks.com/topic/145591-solved-preg-match-error/ Share on other sites More sharing options...
premiso Posted February 17, 2009 Share Posted February 17, 2009 I keep getting a preg match issue where by even a valid number just sets to 0! This is what i have: Why not just use is_numeric or even is_int to check? Link to comment https://forums.phpfreaks.com/topic/145591-solved-preg-match-error/#findComment-764353 Share on other sites More sharing options...
EchoFool Posted February 17, 2009 Author Share Posted February 17, 2009 Because some one used an input of -999999+9999999 and it accepted it with odd results. But i just worked out the issue was a mistake on the $_POST name so sorry to have wasted your time. Link to comment https://forums.phpfreaks.com/topic/145591-solved-preg-match-error/#findComment-764354 Share on other sites More sharing options...
premiso Posted February 17, 2009 Share Posted February 17, 2009 Because some one used an input of -999999+9999999 and it accepted it with odd results. Good to know. I will have to do some tests on that now... Link to comment https://forums.phpfreaks.com/topic/145591-solved-preg-match-error/#findComment-764361 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.