A solution to the μ problem in gauge-mediated supersymmetry-breaking models