عَنْ أَبِي هُرَيْرَةَ رَضِيَ اللَّهُ عَنْهُ أَنَّ النَّبِيَّ صَلَّى اللَّهُ عَلَيْهِ وَآلِهِ وَسَلَّمَ قَالَ: ((إِذَا مَاتَ الْإِنْسَانُ، انْقَطَعَ عَنْهُ عَمَلُهُ إِلَّا مِنْ ثَلَاثَةٍ، إِلَّا مِنْ صَدَقَةٍ جَارِيَةٍ أَوْ عِلْمٍ يُنْتَفَعُ بِهِ، أَوْ وَلَدٍ صَالِحٍ يَدْعُو لَهُ))
It is narrated from Sayyiduna Abu Hurairah, may Allah be pleased with him, that the Noble Prophet, peace and blessings be upon him, said: When a person dies, all his deeds come to an end except for three: (1) ongoing charity, (2) knowledge from which benefit is derived, and (3) a righteous child who prays for him.