Mazda 3 isn't reading gas level. on 2008 Mazda Mazda3

My Mazda 3 isn't properly reading the gas level, I buy a full tank of gas, but when I turn on my car it still shows as empty. The check engine light is on and off, and will remain on if I drive for a while.

Asked by for the 2008 Mazda Mazda3