in the equation: .5kx^2=mgh, notice that both of these energies are not for the initial or the final point, the left side is the energy of the start point that we only got spring, and the right side is mgh, which is in the final place and there is no spring...
i hope I've understood your...