I don't think this is the case - the problem is that your leading zeroes are being chopped off when you are manipulating the string -
Originally Posted by prasanthmj
Strings can still be compared using > and < and string comparison is exactly what you need here as casting the values to numeric and using numeric comparison will just create the same problem.
The database engine knows that for strings 'E' is bigger than 'A' and that '1' is smaller than '2'
When you do $postal + 15, check the value that's returned by echoing it to the screen - is this a string value initially? You'll probably find that PHP is casting the string value to a numeric implicitly for you and then adding 15 to it - of course numeric values don't include the leading zero (it's irrelevant)
What you might want to do is use some sort of string format command to re-add the leading zeroes (all zips must be 5 numerics is that right?) to the string.
I'm not sure which function to use but try something like
I think sprintf can pad with zeroes as shown by this example:
So your code should read
printf("[%05s]", $postal); // zero-padding on string
Give that a try
$postalcode = ' AND den_postalcode < "' . printf("[%05s]", ($postal + 15)) . '" AND den_postalcode >"' . printf("[%05s]", ($postal - 15)) . '"';