(Altec @ Oct. 17 2006,20:55) For what it's worth when you get it working again, think LINUX.
As to the problem, I think the answers have already been talked about, but I'll throw my two cents in. Instead of trying to replace the hard drive, I would consider replacing the power supply first.
I think it is more likely that the problem is a power supply, memory or system board than a bad drive.
If the machine locks up before it even boots to a splash screen then it typically isn't getting far enough along in the boot process to even access the HD yet.
To go a step further, all hard drives will eventually have errors. This is common, but it is the type and severity of the error that will determine whether or not the drive is going to hell. Unless you have continuously occurring errors on the drive, it is hard to tell.
A couple of cheap ways to check to see if it is the memory... Open the box and remove the memory modules. Use a pencil eraser to gently clean to contact points on both sides of the module and then put them back in. If the problem still occurs and assuming you have more than one memory module installed, take one out and leave the other. See if the problem happens again. If it does, switch out the modules. Keep doing this until it doesn't happen or you run out of modules to swap one-at-a-time.
If you get through all the memory modules and it is still happening, then you have pretty much ruled out the memory.
I would go with a power supply replacement at that point. Yes you can get an after-market power supply and install it in a Compaq. Not like you'll void the warranty.
Just make sure the size and connectors are the same as the one you have now. In fact, your current one with you to the store to make sure.
If that no fixxy the problem, then return the power supply and try a hard drive. Most of the time sales ARE NOT final and you can return the product.