Your surfaces need to be clean, smooth and dry, and the pipe needs to be the correct dimensions.
A glued (welded) pipe joint needs to be a snug push-fit connection without the glue, with no play in there. At least in the UK, there are different pipe diameters which are close but not close enough, and these simply won't work because the pipe solvent won't fill the gap. You can get adaptors to join different pipe sizes. Usually you need to twist the pipe in, which is a good thing because twisting ensures you don't get "channels" inside the welded joint.
Then we come to "clean, smooth and dry". Paint and grease are the usual problems here, as well as water if the pipe hasn't dried out for long enough. In your case though, you have a different problem. I can see from the picture that someone has slapped a load of silicone sealant round the pipe, presumably in an attempt to stop the leak. Silicone sealant itself will stop anything sticking to the surface, when removed it leaves stray little flecks of itself behind, and it leaves a greasy surface finish which also stops things sticking to it. I think you need to replace that entire section of pipe, because you'll never get a good joint on a surface contaminated with silicone.
And then of course you need to leave the water off for long enough for the solvent to weld the joint. Check your solvent for details here. Typically they'll say a minimum of somewhere around 4 hours, but I'd personally give it 24 hours (or at least overnight) to be safe.