Chosen Solution

My iphone 4s will only charge sometimes. I have to plug it in and out a bunch of times until it finally charges. but when my phone shuts down and I plug it in once it will charge until it turns on and then the battery is not charging at all once the lock screen loads up?

If you haven’t already, firstly try another charging cable and / or wall adapter. Those are all signs of a bad charging port. Replacing it should do the trick. Where you can buy the part: iPhone 4S Dock Connector Guide to replace the part: iPhone 4S Dock Connector Replacement

if you’re able to check the voltage of the battery would be helpful to know also. It could be the battery either needs a boost or is defective.