Can you get pregnant from sex days before you ovulate?

I actually already know the answer to the question I just asked. But, what I really want to know is how long can sperm survive? (I see so many answers on the internet, from 2 all the way to 9 days after the initial sex). Also, I know sperm can live inside you due to cervical mucus, but does fertile cervical mucus have to be present for it them to survive, or can sperm wait around (a day or 2) for cervical mucus to develop?