A person has to (direct) his intention to Allaah in seeking knowledge-being sincere to Allaah and neither desiring (سمعة i.e. his intention should not be the desire to be heard) nor (رياء i.e. his intention should not be the desire to be seen); neither seeking fame nor a worldly goal from the worldly goals. Whoever directs his intention (sincerely) to Allaah, then Allaah will grant him success and reward him based on that. That is because (seeking) knowledge is worship; rather it is from the greatest (affairs of worship).

Deeds do not (receive) reward, except when carried out for the Sake of Allaah (The Most High) and in accordance with the way of the Messenger of Allaah (sallal laahu alayhi wasallam).  Allaah (The Mighty and Majestic) stated:

[إِنَّ ٱللَّهَ مَعَ ٱلَّذِينَ ٱتَّقَواْ وَّٱلَّذِينَ هُم مُّحۡسِنُونَ– Truly, Allah is with those who fear Him (keep their duty unto Him), and those who are Muhsinun(good-doers)] 16:128

The greatest affair of Taqwah (fear of Allaah) is to sincerely direct one’s intention to Allaah. And besides (the fact that) the one who shows off in seeking knowledge is a loser in the worldly life, he is (also threatened with) punishment in the afterlife, just as it has been (narrated about) those three people who will be thrown in the hell fire on their faces, and amongst them will be a man who sought knowledge so that he is called a scholar and it was said. [1]

[Source: Ar-Rakaa’iz Al-Ashar Lit-Tahseel Al-Ilm pages: 11-12. Some parts slightly paraphrased]

———————————————————————————————-

[1] Abu Hurairah (radiyallaahu-anhu) said: I heard the Messenger of Allaah (sallal-laahu-alayhi-wasallam) saying: Indeed, the first of the people who will be judged on the Day of Judgment will be a man who died a martyr (in battle). He will be brought forth and (Allaah) will make known to him His Favours and he will acknowledge them. (Allah) will say: And what did you do with them? He will say: I fought for your (sake) until I died a martyr. He will say: You have lied; rather you fought so that it might be said (about you): He is brave and it has been said. Then it will be commanded that he dragged on his face until he is cast into Hell-Fire. (The second person) will be a man who studied (religious) knowledge and taught it, and he used to recite the Qur’an. He will be brought forth and (Allaah) will make known to him His Favours and he will acknowledge them. (Allah) will say: And what did you do with (such favours)? He will say: I studied (religious) knowledge and taught it and I recited the Qur’an for Your sake. He will say: You have lied; rather you studied (religious) knowledge so that it might be said (about you): He is learned; and you recited the Qur’an so that it might be said (about you): He is a reciter. And it has been said. Then it will be commanded that he be dragged on his face until he is cast into Hell-fire. (The third person) will be man whom Allah enriched and to whom He gave all kinds of wealth. He will be brought forth and Allah will make known to him His Favours and he will acknowledge them. (Allah) will say: And what did you do with them? He will say: I left no way in which You like that (wealth) should be spent, except that I spent for Your sake. He will say: You have lied; rather you did so that it might be said (about you): He is generous, and it has been said. Then it will be commanded that he be dragged on his face until he is cast into Hell-Fire.”[Muslim. Number 1905]

 

Read more about ‘Riyaa and Sum’ah’ in this link: http://www.sahab.net/forums/?showtopic=25251