This sounds like Rodomonte's Revenge (World of Adventure) by Gary Paulsen. I read this ages ago.
Anyway, a synopsis from the Barnes & Noble websiteBarnes & Noble website:
As Brett watched, one hand slipped loose, then the other. Tom dropped, screaming, into the flames. His body, all red and bubbled, boiled up once to the surface, then was gone. PLAYER ONE HAS ONE LIFE REMAINING. GAME CONTINUES.
Flaming fire rivers. Divebombing buzz-bugs. A cruel king waiting to do battle in his computer-generated castle. Video game whizzes Brett Wilder and Tom Houston think that new virtual reality game Rodomonte’s Revenge is awesome-until it takes over their minds. Then the game playing becomes dangerously real, and one wrong move could be the last.
I'd post a picture of the cover, but 1) I don't know how and 2) it'd be very annoying to do from my phone. But the cover is on the page I linked.