Here are some tips:Melted solder flows towards heat.
Most beginning solderers tend to use too much solder and heat the joint for too long.
Don't move the joint until the solder has cooled.
Keep your iron tip clean.
Use the proper type of iron and tip size.
TroubleshootingIf either of the parts you are soldering is dirty or greasy, the solder won't take (or 'stick') to it. Desolder the joint and clean the parts before trying again. Another reason the solder won't take is that it may not be the right sort of metal. For example you cannot solder aluminium with lead/tin solder. If the joint has been moved during soldering, it may look grainy or dull. It may also look like this if the joint was not heated properly while soldering. If the joint was overheated the solder will have formed a spike and there will be burnt flux residue.