Hello,
I've got an identical problem with an old HTC desire phone, which for several months I had given up on (assuming something wrong had happened with the socket, charging circuit or battery). Today, I stuck it into the USB socket on the laptop and it started charging. Completely weird. (I've tried it in 3 different wall chargers - one via the same usb cable to rule out the cable).
I've two theories:
1. I wonder if USB Debugging or some other software on the phone is causing problems.
2. This is my favourite, but is a long shot. Besides data and id, there's +ve and -ve pins on the usb cable. There's also the shield. I imagine a lot of designers would connect the shield to the negative pin (just had a look online, there's some uncertainty but eg.
http/forum.allaboutcircuits.com/showthread.php?t=58811 ). If the negative pin connection on the phone's socket was broken (e.g. a solder-point failure etc) then, if the shield was connected to ground at both ends it would luckily provide an alternative route. I imagine on a laptop the shield is also grounded. I wonder however, maybe in wall-chargers the shield is not grounded: So when you connect it to those chargers the -ve can't get to the phone, and so it can't charge. Just an idea, not sure how to prove it at the moment (just moved to Kampala, and don't have my electronic equipment, but anyone with a multimeter could check if the shield is connected when plugged into different chargers.