My iPhone 4 won't charge when on but will if it's off?

I've tried cleaning out the charging port. When I plug it into the docking station or try any of the chargers I have, it doesn't even make a noise or show the lightning bolt. I've tried resetting it by holding the home button and lock button, doesn't work either. But once it's died, I put in the charger (any) and it starts charging. But THEN when it comes back on, it has about 5% battery and it's not charging anymore even if I take it out and put it back in, so it's a vicious circle. I don't know what to do?

Is your charger made from apple or did you buy it from somewhere else? You will need to buy a new charger. My iPhone 5c charger broke and it won't charge so i have to get a new one. Wires are probably damaged inside

My Iphone4 did the same thing. Now it won't even charge anymore, sadly you're going to have to get a new one or send it in to Apple its an internal hardware issue.

Try to update your software to the newest iOS and make sure you have an Apple brand charger and adapter. If that fails then take the phone to an apple store or buy a new one (iPhone 4s is free at many stores which is newer than your phone).