This could be a battery issue if you have another to try start there if your getting a connect disconnected it sounds like it could be the charging port itself . Try wiggling the cord and see it there's a position that will allow it to charge
http://www.amazon.com/Original-Genuine-Connector-Replacement-HTC/dp/B008RECYG4/ref=sr_1_2?ie=UTF8&qid=1443301963&sr=8-2&keywords=htc+desire+510+charging+port
the port can be purchased on amazon and is a separate unit so its screw in and hook up your cables and away you go