Nur2652 when you say that it charges when it's 'off', do you mean when you put the phone to sleep or lock it? The iPhone's actually do not charge while they're turned off, it will power the device on and then charge it. However, it sounds like it is a software issue. You may need to attempt restoring the device(as new) to test. You can always take it to your nearest Apple store and they can run a diagnostics on it to see if there is an issue with it(no charge even if out of warranty for this test).