Clean the back of your credit card with a damp cloth. Even if it appears clean, that doesn't mean that it is. Small particles of dust and dirt on the magnetic stripe can interfere with information transmission, causing a merchant terminal to reject the card.
Ask the cashier for a plastic grocery bag. Place your card in the plastic bag, hold the bag tightly against it and swipe it through the terminal. The plastic creates a larger gap between the coding in the card's magnetic stripe and the terminal. The terminal still reads the card but, due to the gap, will ignore small variances in the stripe's magnetic particles that otherwise would have resulted in a rejected credit card.
Place a piece of clear tape over the magnetic stripe. Like placing the credit card in a plastic bag, clear tape still allows merchant terminals to read the coding, but creates a gap significant enough that terminals ignore small coding errors.
Hand the card to the cashier and ask her to key in the card number manually. While doing so is more time consuming than swiping the card through a terminal, it allows you to continue to use your credit card when the magnetic stripe cannot be read.