So I was putting a fresh set of Roto's on my bass after trying Ernie Balls, and all of the sudden, as I was tightening the D string up to pitch, the string went slack. My machine head had gone totally loose, I can now screw it off with just my fingers. What should i do?
Tuning pegs are easy to replace but if you move away from stock/standard for your bass, be sure to measure the hole circumference before your order one.

Also--did you check to make sure everything is tightened the way it should on the machine head?