What to do if my iphone won't keep a charge to it?

I have an Iphone 3GS black. I just bought a charger plug for it 4 days ago @ the store & it was working just fine every since then. I've noticed i was having a problem charging it last night. Every time i plug the usb cable cord in the wall plug, a message pops up on my phone "charging is not supported with this accessory". Now it usually would say that if i have an extension usb port plug, plugged to my computer.
But in this case, i'm having a problem with my iphone. I have this same problem many times before with other usb cable cords. I don't know if the problem is with the cable cord, or the usb port on my phone. Can I please get help with this?

Iphone 5 won't connect to computer at all but charges when using wall charger? - 1

I've just got an iphone 5, it bought it from ebay and everythings fine. However, when connecting it to the computer nothing seems to happen - the phone doesn't charge and the computer or itunes doesn't recognise it. When using the same cable with the wall charger it charges… What can i do? I can't go to Apple as i don't have a receipt?