I think the main thing to do is acknowledge that you can't always help every person you talk to. Like Yourlostlove said above, sometimes people don't want advice. But that doesn't necessarily mean that you aren't helping them if that's the case. Sometimes just typing it out and knowing someone is there to read it is enough.
If you really feel like you don't know what advice to give, the best thing is to sympathise with the venter. Saying things like, "I can't imagine how hard that must be for you" or "I think you are incredibly brave for speaking to someone about this" can really boost someone's confidence and make them feel a little better.
It's probably best to avoid repeating "I know how you feel" as depending on how serious the issue is, it can deviate from their own feelings and make them seem less significant, even if unintentional!
I hope you're having a good day xx