A nonlinear elliptic equation with singular potential and applications to nonlinear field equations