Make sure the charging ports are clean and free of debris or dirt. If required, wipe them down with a soft cloth.
Make sure the USB cord is in good working order. To test if it's working properly, try using alternative USB cords (if available).
Other appliances should not be plugged into the same power source/outlet that you use to charge your iPhone. You might also try to utilize any other accessible functional power outlets.