A method of foaming a fluid for recovering gas from a gas well and enhancing oil production from a gas-lifted oil well penetrating a subterranean oil-bearing formation is disclosed and claimed. The method includes introducing into the fluid a foam-forming amount of a composition comprising at least one compound having the general formula:
R1 is selected from a saturated linear or branched alkyl, an unsaturated linear or branched alkyl, a substituted naphthalene, a substituted benzene, a natural oil, and a natural oil derivative. R2 is a C2-C8 alkyl. R3, R4, and R5 are independently selected from trimethyl, triethyl, diethyl, monoethyl, benzyl dimethyl, and benzyl diethyl. X is selected from hydrogen, methyl, and ethyl. Z− is a negatively charged counterion.