Why are you adding 180 to negative values? For one thing the sign on those numbers is important... for another, -10W does not equal 170E.... Whatever you were attempting to do, I think abs($long) would be better than $long+180.
-Blake
Comment on Re: Getting longitude and latitude from an IP address