An iPhone charges faster when it is plugged into a wall outlet, using a USB cable and the power adaptor. If you decide to use the USB port on a computer, the iPhone will still charge, just a bit slower. If it doesn't charge at all, there are a few reasons why it might not be receiving power.
FireWire was developed by Apple and Texas Instruments and is capable of providing power to peripheral devices. The first generation iPhone is the only version that can charge through a FireWire power source. If you don't have one of the original iPhone's, you will instead see the following error: "Charging is Not Supported with This Accessory."
When the computer goes on standby it is "asleep," and it will stop charging the device. If the computer is on hibernate, it has been completely shut down, and no power is provided to the USB ports. If you are using a laptop, do not close the lid or it might trigger it to go to sleep. The exception is if you have a laptop with "Sleep n' Charge," which means certain USB ports will continue charging even when the laptop is turned off.
It is possible that the USB port you are using has gone bad. This could be due to a power surge, static electricity or a simple malfunction. Plug the iPhone into a different port to see if it will charge. If the USB drivers are corrupt, you can re-enable the ports by reinstalling the drivers. Type "Device Manager into the Start menu, and press enter. Click to expand "Universal Serial Bus Controllers," right-click the first entry. Click "Uninstall," and repeat for the remaining entries. Restart the computer and the USB drivers are automatically installed.
A USB cable is more likely to go bad than a USB port. If you've had the cord for a long time, you may notice areas where it is worn and the wires stick out. Even if it is in perfect condition,a malfunctioning cord might stop charging completely. In addition, if your cord was made by a third-party, it may not be compatible with your device. Purchase a genuine USB cable made by Apple for the best results.