Previously when i prayed salah and I had food stuck in my mouth; I used to quickly spit it out in front of me. However my sister said to me not to do that and that my prayers could be invalid. Are my prayers invalid if I was ignorant of a ruling? Plus I don’t remember how many prayers I did whilst spitting out food.
Spitting in the direction of the qibla while in prayer is a serious offense and insulting to Allah. The prophet salla allahu aliahi wa Sallam ordered that we do not allow such a person for leading the prayers.
However, if you were ignorant of the ruling and repented, Allah is most forgiving.