The opposite of knowledge is ignorance, which is of two types:
1—Ignorance of the legal ruling: that is, not knowing that a matter is unlawful.
2—Ignorance of one’s circumstances: that is, not knowing that one is in a state in which eating and drinking are prohibited. Both are valid excuses.
The evidence for this is Allah’s saying:
“Our Lord, do not impose blame upon us if we forget or make a mistake.” [al-Baqarah 2:286]
When accountability is waived, whatever follows from it is likewise waived. This is general evidence.
There is also specific evidence in this matter for both types of ignorance.
As for ignorance of the legal ruling, its evidence is the hadith of ‘Adi ibn Hatim, may Allah be pleased with him: when he wished to fast and read Allah’s saying:
“Eat and drink until the white thread of dawn becomes distinct to you from the black thread of night.” [al-Baqarah 2:187]
he brought a black tethering cord—a rope used to bind a camel’s foreleg—and a white tethering cord, placed them beneath his pillow, and continued eating while looking at the two cords until the white cord became distinct from the black cord. He had misunderstood the verse, for what is meant by it is that the white thread is the light of day and the black thread is the darkness of night. When he came to the Prophet, peace and blessings be upon him, and told him, he said: “Your pillow must indeed be broad, if it accommodates the white thread and the black thread.” (1) He did not command him to make up the fast, because he was ignorant and had not intended to disobey Allah and His Messenger, peace and blessings be upon him. Rather, he believed that this was the ruling of Allah and His Messenger, peace and blessings be upon him, and was therefore excused on that account.