I need some help with this one guys. I made a small script that inputs only numbers with 4 digits. Now the trick is that I need to input only numbers higher than 0 (ranged from 1 to 9999). Easy enough, I said, if I only make this rule: $val<=0. But the problem here is that if I input the number 01 or 001 or 0001, it is submitted to the query. I could do this: $val<=1, but then I would need the number 1 to be submitted so this didn't get me very far. Is there a way around this!? Thanks.
seularts
0
Light Poster
Recommended Answers
Jump to Postyou could do an intval() on the input?
check this:
<?php $int = '0001'; echo intval($int); ?>
Jump to Postif($val > 0 && $val <= 9999){ $val = str_pad($val, 4, "0", STR_PAD_LEFT); //bla bla bla submit to query }
unsure about why,
sql will strip the leading zeros and process only the value of the column anyway,
not valid as a verification tool, to ensure no …
All 5 Replies
diafol
almostbob
866
Retired: passive income ROCKS
seularts
0
Light Poster
seularts
0
Light Poster
diafol
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.