Abdullah bin Umar reported,

The Messenger of Allah ﷺ said, "Whoever sees someone afflicted and says, 'Praise be to Allah who has spared me from what He has tested you with and favored me greatly over much of what He has created,' will not be struck by that affliction."

Azami 11303

Hasan

عن ابن عمر قال

قال رسول الله ﷺ: من رأى مبتلى فقال: الحمد لله الذي عافاني مما ابتلاك به، وفضلني على كثير ممن خلق تفضيلا لم يصبه ذلك البلاء.

الأعظمي 11303حسن
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Supplications, remembrances, and prayer upon the chosen Prophet ﷺ
Chapter
Supplications for various occasions
Section
What to say upon seeing an afflicted person
Numbering
Jami al-Kamil 11303 (2nd edition)
Azami 11303