I bought an iphone 5 cable but it only charges when i turn it off why?

I bought an iphone 5 cable but it only charges when i turn it off why? What can i do

I had a similar problem and this may not be your problem but for me I have an iPod touch and when I plugged it into my room at my dad's house it would only work when it was off. So I went to the store to but another charger. It worked until I plugged it into the same outlet at my dad's house an it stopped working. So I finally figured out it had to do with the outlet in the room somehow ruining the charger so I recommend you buy another charger and don't use that outlet again. Hope I helped, long as an answer as it was: P