1. Prevention is the best medicine
You've heard body building tips like this one before because it's true. You can prevent most injuries in the gym from occurring in the first place. Keep your mind on what you're doing and go to the gym with a plan.
If you're just walking from one exercise to another with no clear goals or plan in mind you will eventually injure yourself. This can occur when you create a muscle imbalance.
For example, if you always work your quadriceps (the muscles on the front of your thigh) and don't work your hamstrings (the muscles on the back of your thigh) in the same manner, you will create a muscle imbalance.
You will have one stronger muscle pulling against a weaker muscle. In this case, you will likely injure you knee.