These USB issues are tough to troubleshoot. The easiest thing to start with is the sync cable, borrow one from a friend to try if you don't have an extra. The iPhone should still charge from a USB port even if the computer does recognize it, try it with another computer.
If the iPhone does not charge using other sources it is probably defective. First try resetting the iPhone by holding the Sleep and Home buttons till you see the Apple icon. As I stated above, try other sync cables, computers and chargers. If it doesn't charge using other power sources chances are your iPhone is having hardware problems. Take it to an Apple Store or you cell service provider for repairs.