In addition to the answer by Spehro:
but the solder kept melting in balls like the one on the first tip of the image.
That's a cold solder joint. If you look closer at it, you can see that the solder doesn't cover the whole pad as it should. It rather just sits on top of the pad. This happens when both metal areas aren't heated sufficiently at the same time (hence "cold"), or when one or both areas is polluted. Could be remains of oxidation or the old joint etc. You should have started by removing the old joint with a thin wick braid. Then ideally clean with isopropanol or similar and add flux.
Even if you clean up the old joint OK, you still have to carefully place the iron tip so that it touches both the pad and the pin at once. Hold for a few seconds, then add solder by having it touch the pad - you shouldn't need to have it touch the solder iron to wet, if the surface is hot enough. The classic newbie mistake is just to melt the solder by feeding it directly against the iron tip. Then all flux will vapour quickly and the metal surfaces aren't necessarily hot enough, meaning that you end up with a messy blob.
You could salvage this joint if you flux, then press the the tip of the iron through the existing solder, again so that it heats both the pad and the pin at once. The solder should wet to cover both metal surfaces and look like a cone with concave sides, glistening like silver if you use leaded solder, otherwise matte if you use RoHS solder (harder to work with).
If you don't have a flux pen or similar external flux, then remove the joint completely and start over.