have you tried multiple chargers? If the issue persists with multiple chargers, the issue is at the iPhone.
Try connecting it to iTunes and see if it's recgonized there.
Also, here are some other steps:
1. Try doing a hard reset:
Press and hold both the Home button and the Sleep/wake button simultaneously for about 15 seconds and release when the Apple logo appears.
2. If that doesn't solve the issue, backup the device and restore it as new.
In that case, use: http://support.apple.com/kb/HT4137
NB: set up as a NEW device because a software issue will be in the backup. If the issue persists after restoring as new, you should offer the device for service.
If you get specific error messages/codes in iTunes when updating/restoring, check this: http://support.apple.com/kb/ts3694 for causes and solutions
If you're not able to restore the device, you should use: http://support.apple.com/kb/HT1808
Using that last article will erase everything on the device, so make sure you have a backup!
NB: If you're not able to restore the device at all with any computer, it defenitely needs a hardware repair.
Good luck 🙂
JW