Generally speaking, if the gym is reputable and well maintained, then the risk of contracting something contagious from the shared gym equipment is relatively low. There is, however, a risk of contracting fungal infections from the gym. Fungus live on the skin and they cause conditions like athlete's foot and nail infections. They tend to thrive in humid, moist environments like those you find in a gym.
In order to minimize your chances of contracting fungus, make sure to only use gym equipment after it has been cleaned (a gym attendant should be cleaning the machines between clients). Additionally, you should always wear shoes in the gym, especially while on the machines, but also in the locker room. If possible, bring a pair of shower sandals for the shower (as shower stalls are one of the places where fungus is most likely to accumulate). Avoid sharing towels with anyone else.
If you follow these procedures, you should be relatively safe. However, if you notice any spots on your skin that look like athlete's foot or another fungal infection, go see you primary care doctor
right away, who can prescribe something to take care of the infection for you.