What happened is you did not properly establish the biofilter.
The easiest way to start a biofilter is to start with 1 feeder goldfish per 5 gallons of water. Get the good test kits.
The best biofilter is either an under gravel filter or a external filter that has a biowheel. Ask the pet store for a cup of gravel from an established fish tank.
Fish produce ammonia which is bad for fish as it builds up, and there is a bacteria that converts ammonia to nitrite which is bad for fish, and there is a second bacteria that converts nitrite to nitrate that is relatively harmless to fish. It's called the nitrogen cycle.
Watch the chemistry levels with thew test kit - you will initially see the ammonia levels spike, then it will start to drop and nitrite will start to spike. Then after a few weeks the nitrite level will go down and the nitrates will start to rise.
Once you ammonia levels measure 0ppm and the nitrite levels measure 0ppm, the biofilter is established. Discard the goldfish, adjust the temp and and ph to the requirements of the fish you want to keep, and get the fish you want to keep.
Another method I have used quite successfully is called "fishless cycle" - you set the fish tank up but do not get any fish. You use pure ammonia to start the cycle, but make really sure it is pure ammonia (diluted in water) - absolutely no detergents or scents or other stuff added. Walmart carries it, or at least use to, for about 99 cents a bottle.
In a 5 gallon bucket, figure out how many drops it takes to raise the ammonia level to 5 parts per million (use your test kit). Write that number down - so you know how many drops to add to your fish tank. (IE for 20 gallon, you would multiply that number by four).
Get some gravel from an established fish tank, and with NO FISH, add the right number of drops of ammonia to spike the tank to 5 parts per million. Do not add any more ammonia until the ammonia level has dropped to 2 parts per million (indicating the ammonia eating bacteria is reproducing) - you will start to see the nitrite level spike. At that point, add HALF the original number of drops of ammonia every day and monitor the ammonia and nitrite levels every day.
The ammonia level will eventually drop to 0ppm 24 hours after adding but the nitrite level will spike. Then the nitrite level will start to drop and nitrate level will start to spike. At this point, add live plants if you want them.
When the ammonia level shows 0ppm 24 hours after adding ammonia and the nitrite levels show 0ppm 24 hours after adding ammonia, your biofilter has been established. Stop adding ammonia, and 24 hours after the last time you added ammonia, you can add fish.
The nitrates - they are harmless to fish but can cause excessive algae growth, so when the nitrate levels reach 40ppm, change 20% of the water. The removed water is great for your garden.
Anyway - for further details, google "fishless cycle" and "fish tank nitrogen cycle".
-----
Arrrggg!
It's like Shalom, but for pirates.
- iCarly