Milligrams and gallons are separate units of measurement and cannot be compared. If the item in question is water, however, 1 gallon of water is typically equivalent to 3785.411784 milligrammes of water.
A milligramme is a unit of mass measurement, while a gallon is a unit of volume measurement. 1 milligramme of water occupies exactly 1 cubic centimetre. UnitConversion.org states that 1 gallon is equivalent to 3785.411784 cubic centimetres. However, not all chemicals possess this straightforward conversion. Different substances have varying densities. Density is the mass per unit volume ratio. Depending on the altitude at which the measurement is conducted, the previously indicated conversion of water may not be accurate.