Latitude and Longtitude Distance Calculation
Okay, few notions about your procedure


DECIMAL(12,12) means 12 digits, where ALL 12 are behind a
floating point (so basically, 0.*). To see an example, execute
SELECT CAST(23.45 AS DECIMAL(12,12)); and see what output does it
give you.
I suggest that you change DECIMAL definitions to DECIMAL(9,6)
which means 9 digits, where 6 are after the point. I think that
would suffice for your calculations.
Why are you escaping all your numbers?
Why are you using SELECT xx INTO yy for setting variables? Why
don't you just use SET yy = xx;?
Your function returns INT, which means that it will cancel
everything after the floating point. Is this what you need?


If you change all your decimal definitions properly (even the input ones), I think that your function should return proper result then (altough without the floating point). After that unquote your numbers (there is no need to quote them, even in your select query).

Let me know how it works out.