I have this problem sometimes and have come to realise it is usually caused by the PC using the wrong driver for the device. The device manager in Windows lists hardware and what drivers are installed. This may help you see what driver the device is currently using.
I have downloaded the correct drivers for my dtevice and have installed them correctly. I have noticed that sometimes Windows will update the usb driver for my device and install their own microsoft driver which causes the device to not be recognized by pc, but allows you to charge the device. I fix this problem in device manager by uninstalling the device. Next I reboot the operating system and the PC usually will install the correct drivers and my device is again recognized on the PC.
So make sure you are using the correct drivers for your phone or the PC will likely not recognize the phone and will only charge it's battery. Make sure you have the proper cable too.