Sayyiduna Abu Hurayrah (may Allah be pleased with him) narrates that the Prophet (peace and blessings be upon him) said: "When any one of you sees someone in some trial (an affliction, illness and the like), let him recite:
'Al-hamdu lillahil-ladhi 'afani mimmabtalaka bih, wa faddalani 'ala kathirin mimman khalaqa tafdila'
(All praise belongs to Allah, who has kept me safe from what He has afflicted you with, and who has greatly favoured me over many of those He created.) The Prophet (peace and blessings be upon him) says: When a person recites these words, he will be counted as one who is grateful for that blessing."
(Allamah al-Haythami says:) I say: Al-Tirmidhi recorded this report in abridged form.
Al-Bazzar recorded it, and al-Tabarani recorded something similar in al-Mu'jam al-Saghir and al-Mu'jam al-Awsat, and its chain is hasan (good).
Hadith Referenceمجمع الزوائد ومنبع الفوائد / كتاب الأذكار / 17138
Hadith Gradingمحدثین:إسنادہ حسن۔
Hadith Takhrij«اخرجه الطبراني فى المعجم الصغير (675) اخرجه البزار فى المسند (3118) ، أخرجه سنن الترمذي برقم: 3431، 3432، وأخرجه البحر الزخار المعروف بمسند البزار 10 - 18 برقم: 9106»