A proximity search using latitude and longatude will be incredibly slow, I wouldn't advise it. The query above will return the lat and long for the IP. You would then have to do some lat/long calculations for your 5 mile raduis and add a where clause, something like the following:-
WHERE latitude BETWEEN $min_lat AND $max_lat
AND longitude BETWEEN $min_long AND $max_long
Check out this thread for raduis calcs using lat and long:-
http://www.experts-exchange.com/Database/GIS_and_GPS/Q_23027761.htmlIf youcome up with some code to debug, I'd be glad to help you with that. It's quite unreasonable to expect the code to be written up for you though.