You should contact the author of the paper first, and ask some questions. These questions should be non-judgmental. The problems you found with the paper may not be known to the author, nor was it their intention to publish with such errors present. You have not given details regarding the paper, or what can be determined in the course of events regarding that author's research. But your totally objective and unbiased questions regarding the results may bring to light problems that this author is now seeing for the first time. They may wish to correct these mistakes.
This may open a collaborative effort that ultimately becomes quite productive and rewarding.
What else can you do? Put yourself in their shoes, and presume at the start they do not know of these problems. State you found this author's paper interesting regarding a problem in the nexus of your own ongoing research. You do not have to reveal more than necessary (in asking some questions) other than to say you are doing some background research (you may, or may not, be at liberty to discuss). See what they have to say, and note how they respond. You can set boundaries regarding how much you wish to discuss, and see how things develop from there. But be honest. Trust will come but not all at once. Keep in mind, this author may have adverse feelings about your asking questions regarding noted errors in this paper. Do they know you and can they trust you? They may get defensive, and you should be prepared for this. You may have to let go of discussing this issue, altogether.
Contacting the journal may not be a good idea. What are they supposed to do? A better way to approach this problem is in the publication of your own research. If the effort is collaborative with this author, then all is well. But, if you have to go it alone, do not directly mention that errors were found in another's work, or be critical. Rather, a more or less casual statement that is to the point, for example, would be to state that among papers X and XY discussing this problem, the current work provides an updated view of the analysis and results. No judgements, no discussion of errors or criticisms, just some objective and forward-looking comments and statements. Keep in mind, the author of the work we are discussing may be waiting for your work to be published. There is no reason that this author should feel badly about comments you may have regarding their work. There is no reason to leave adverse consequences for anyone.