Chosen Solution

I bought an iPhone 3gs from eBay and it sometimes turns on and shows a dead battery charging screen then an apple logo then after a few seconds turn off. can someone help me it goes basically like this

You need a new battery.