All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
The wording of the supplication of Khaalid when he drank the poison which we have come across is close to the version that you heard from the lecturer.
Ibn Katheer reported it in his book Al-Bidaayah wan-Nihaayah with the following wording:
“In the name of Allah, the best of names, the Lord of the earth and the heavens, with Whose Name nothing (no illness) can cause harm, the Most Merciful, the Ever Merciful.”
In the Musnad of Abu Ya’la, the wording of the narration only mentioned that Khaalid said: “Bismi Allah” (in the Name of Allah), and then he drank it, and it did not cause any harm to him.
The scholar who checked the authenticity of this narration commented saying: “Its men (in the chain of narration) are trustworthy but the chain is disconnected”, meaning that this narration is inauthentic.
If all these narrations are authentic, then this can be interpreted that one of the narrators summarized the wording, or other interpretations that the scholars may have provided to repel what could appear to be a contradiction.
There is nothing wrong in saying such a supplication sometimes before eating, but it should not be taken as a habit. Ibn Abu Shaybah narrated that Ibn Mas'ood said: “Whoever says when he puts down his food [on the table to eat]: ‘In the Name of Allah the best of Names, to Allah belongs whatever is on the earth and the heavens, with Whose Name nothing can cause harm, O Allah put blessings and a cure in it’; then that food will not harm him no matter what kind of food it is.”
Nevertheless, we did not come across any scholar who ruled the abovementioned narration to be authentic or inauthentic. If it is authentic, it is evidence that it is permissible to say it before eating food.
As for the narration by Anas; it was reported in Musnad Al-Firdous by Ad-Daylami, but we have not come across any scholar who classified it as authentic or inauthentic, but the Musnad Al-Firdous includes inauthentic Ahadeeth.
Allah knows best.