Restore original 2 lines about unsetting array
makesafe to intval
Remove function, replace with sql manip