I made a diamond sword and enchanted it, I got Sharpness III then I went to my anvil and changed the name of the sword, finally I combined the sword with an enchantment book that contained Bane Of Arthropods IV. My sword didn't change, it still only has Sharpness III and the edited name but no BoA IV. Can anvils fail or was this a glitch? I lost the book and the enchantment levels.
You can't put Bane of Arthropods on a sword that already has Sharpness; unfortunately, the game lets you try to do so anyway; this also applies to any form of Protection (Protection, Blast Protection, etc) and Fortune and Silk Touch on tools.
Also, the tooltip on the output item lets you see what enchantments it will have before you take it out and waste experience/books (and in 1.8, increase the prior work penalty, using up one of just six possible anvil workings - you really don't want to combine books or items because of this if you want long-lasting items - this also includes renaming, which only keeps the cost from increasing in 1.7.10 and older versions, note also that in those versions it is cheaper (if the cost allows) to rename at the same time you repair or add enchantments).
Also, the tooltip on the output item lets you see what enchantments it will have before you take it out and waste experience/books (and in 1.8, increase the prior work penalty, using up one of just six possible anvil workings - you really don't want to combine books or items because of this if you want long-lasting items - this also includes renaming, which only keeps the cost from increasing in 1.7.10 and older versions, note also that in those versions it is cheaper (if the cost allows) to rename at the same time you repair or add enchantments).
TheMasterCaver's First World - possibly the most caved-out world in Minecraft history - includes world download.
TheMasterCaver's World - my own version of Minecraft largely based on my views of how the game should have evolved since 1.6.4.
Why do I still play in 1.6.4?