Is it OK to just buy the ticket at the train station and not book on line - it seems cheaper but I'm worried they will be sold out.
On some international trains in Europe reservations are required so you should check ahead like Steve suggests.
On the other hand I know there are several trains a day from Prague to Budapest, so unless reservations are required, you probably don't need one.
According to the timetables on the German Rail site, www.bahn.de, there are direct EC trains from Prague to Budapest departing at 07:39, 11:39, and 15:39. Reservations are recommended but not required.
You can book a ticket plus a seat reservation on any of those daytime trains by phoning the DB (German Rail) ReiseService. Dial 011 (US international access code) + 44 (country code for Germany) + 8718 80 80 66. You will pay the same fare as you would if you bought a ticket at the station in Prague.
There is also a direct night train for which reservations are required.