What is the ruling of masturbation? Please can you give some advice.

Masturbation is defined as using the hands on the genitals with sexual desire to cause the ejaculation of sperm. This habit is unlawful and the evidence for its unlawfulness is the statement of Allaah, Most Exalted,

(إِلَّا عَلَىٰٓ أَزۡوَٰجِهِمۡ أَوۡ مَا مَلَكَتۡ أَيۡمَٰنُهُمۡ فَإِنَّهُمۡ غَيۡرُ مَلُومِينَ ‘وَٱلَّذِينَ هُمۡ لِفُرُوجِهِمۡ حَٰفِظُونَ)
… and they who guard their private parts except from their wives or those their right hands possess, for indeed, they will not be blamed.” (Al-Mu’minoon 5-6)

This aayah restricts sexual activities to be only with wives or female slaves owned by the person. Therefore, this implies that anything other than the aforementioned is unlawful. Furthermore, the Prophet ﷺ said,

Young men! Those from you who are able to marry, they should marry, because it helps the most to lower the gaze and remain chaste. Those who are unable to marry, let them fast, because that will reduce sexual urges.” (Bukhaary 5066)

From what has been discussed regarding masturbation, even if it were regarded as permissible, is that the jurists of the Hambaly school and others were of the view that, ‘If anyone masturbates for no reason, he is punished.’ This means that if a person is afflicted with severe sexual desire and has no outlet except for masturbation, it is said according to the legal ruling regarding doing the lesser of two evils, the other evil being fornication, it should be done, but it is not said that masturbation is permissible. However, a person should not put himself in the way of sexual temptation. Hence, he should not look at women nor go to their shops, or watch television, magazines or newspapers which contain illicit pictures. Rather, he should protect himself from these. This is in order to prevent himself from committing what is prohobited, because masturbation is only allowed due to an extreme need. A person must take all precautions to prevent arousing sexual desires. If by accident or an event out of his control he is sexually aroused and has no outlet except for masturbation and the urge is severe and out of control, the lesser of the two evils may be carried out, and that is what the scholars meant when they said, ‘If anyone masturbates for no reason, he is punished,’ even though the basic ruling is that it is not permissible. Also, it has been recorded in a very weak hadeeth that the        Prophet ﷺ said,

“Allaah curses such and such… and the one who masturbates.” (Majlis hadeeth, Hadeeth gathering, from Shaykh Ibn Hayyan Al-Asbahaany and others, manuscript 5)