Measurement of the Casimir force in a gas and in a liquid