I am a PhD student in mathematics. I recently found a fundamental error in a method used in a series of papers. My adviser confirmed that. One of those wrong papers was authored by a researcher who had several works with my adviser. I found that this error can be fixed using an approach which I found in some old works. So I started to write an article about this. I am just asking if I should tell my adviser to contact him and inform him about this error. Or contact all the authors of those papers. Or just continue writing my paper and cite their works explaining how their approach is wrong.
Talk to your adviser as soon as possible. I'm a bit surprised that in your previous interactions your adviser did not already tell you whether and how he planned to contact the author(s) of the fallacious papers -- especially given that at least one was your adviser's collaborator.
Here is my advice (it comes from a pure mathematician, if that is relevant to you):
The point of this is that in many cases what we perceive to be errors in mathematical work stem from misunderstandings between the reader and the author, including different use of the same terminology. I would say that approximately half of all the errors I think I see in my colleagues' work turn out to have such innocent explanations. Another big percentage of suspected errors stem from misunderstandings of the part of the reader: it is one thing if you come across a result that contradicts another result you have already written up. However, if you are just reading then the odds are fair that the cognitive dissonance in your mind is not actually caused by a mistake in the paper: for instance when I read other people's work, I try to do so with an eye towards its relationships to my own work and my own problems. As a proud student of the "Richard P. Feynman school of situational genius" I heartily endorse this approach, but sometimes it turns out that what I think is an error is due to an entanglement of "my situation" and the author's. Finally, when an error has actually been made, there is usually (very understandable) psychological resistance on the part of the author. This is why it helps to arrive with individual, crisp counterexamples.
Everyone has different standards of what constitutes an acceptable proof. Moreover, mathematicians are still human beings, and the percentage of inessential slipups we make in the course of our written work is non-negligible. Most people do not appreciate their expository flaws and bone-headed but unimportant mistakes being taken as evidence that their proofs are incorrect. In fact, where possible, when you claim that someone's proof is faulty it is an honorable thing to give them a chance to correct it.
In this case you speak of a "fundamental error", which I guess means that it is worse than the relatively innocuous mistakes described above. Do you mean though that the theorems are still true, and you know this because you know how to prove them? If so:
I would meet with your advisor as soon as you have written each document. (If you can write both in one day, great.) Then the question becomes obvious and unavoidable: what should you do with these documents? If he can vouch for their accuracy, I think you will certainly want to contact the author of the flawed paper, but whether to do this yourself or through your adviser is something you should ask him about.
Why do I place time limitations on these tasks? It is because of the following important observation, which in my understanding is somewhat peculiar to mathematics:
There are too many nuances here for me to go over them all, but just one quick thing: you say that you fixed the result using material from old works. Because of this, it is possible (perhaps; I don't know the situation) that the authors and/or the editors in question will still regard the mistake as a "slip up" (even if you do not). A math paper which does not contain "new results", "new ideas" or "new techniques" may be very hard to publish...let me readily admit that this practice is not entirely fair or wise, but it most certainly is extant. So you don't want to spend substantial work time on what may end up being a corrigendum written by the author but identifying you as the provider of both the problem and the solution.