Bismillaah:

Ibn Umar and Abu Hurairah رضي الله عنهم both said:

The Prophet صلي الله عليوسلم said:

" If one sees an afflicted person and says:

الْحَمْدُ لِلَّهِ الَّذِي عَافَانِي مِمَّا ابْتَلَاكَ بِهِ وَفَضَّلَنِي عَلَى كَثِيرٍ مِمَّنْ خَلَقَ تَفْضِيلًا

Alhamdu lillahil lazi afani mimma ib-talaka bihi wa faddalani ala kathiran-mimman khalaqa tafdeela

" Praise and thanks be to Allaah Who has saved me from what he has afflicted you with, and has honored me over many of His creatures,

he will be saved from that affliction."

Takhreej:

{ Imam At Tirmidhi in his Jaami and he said hadeeth Hasan Ghareeb }

Imam An Nawaawi رحمه الله commented:

The scholars said, one should say the above mentioned supplication inaudibly so that the afflicted person should not hear it, lest he should be grieved by it. But if the affliction is the result of his sinful conduct then there is no harm in his listening if he is not heedful of evil."

{ Kitaab Al Adhkaar }

*** And Allaah عزوجل knows best ***