My iPhone say charging is not supported with this accessory, why?

I bought this iphone 4 of ebay and it came with a cable. I had it for 3 weeks and now it has started doing this yellow triangle when i'm charging it. It takes forever to charge and its really annoying! On top of this i have to hold it in a specific way to even get any connection when charging
any help will be greatly appreciated! 10 points!

Mine will do that if the charger is put in weird or not fully plugged in… I would try to reset phone or get a new charger. I switched chargers and mine worked fine

I have had this problem too. Try plugging the cord in again.

It can be two things: This happens to my iPod Touch 2nd gen, but it doesn't happen a lot, only slightly, and it only happens if the wire is in a certain position. Not too sure why then the iPod can't figure out that it's the charging wire but anyway. So the other thing is that your battery is in a bad condition so your going to have to get it repaired, but I would just get a new charging wire and see how that is because to get a new battery for an iPhone would be a lot more than a simple wire. Hope this helps