Sounds like your monitor cable is loose or shot. Check both ends don't have any bent/broken pins and are firmly attached. Also try "wiggling" the cable; normally the end that goes is the end near the monitor, but try both.
If you have bent or broken pins, replace the cable. If wiggling helps, taping the cable into a position that "works" will help in the short term, but you should probably replace the cable before it drives you mad. Shop around - you can pay between �2 and �30 for a cable.