Your phalanx line may not be as wide as the charing cavalry, which would cause some cavalry to circle back around and hit your phalanx from behind.
Most if not all the battles I've played, anything charging into phalanx's from the front get completely annihilated.