Am3 will not work in an AM2 socket. And DDR3 will not run in a DDR2 slot PC2-6400 is DDR2 800 ram.
Now on the other hand AM3 can sometimes run in a AM2+ socket.
This Phenom is an AM2+ http://www.newegg.com/Product/Product.aspx?Item=N82E16819103471
It should run but i would ask compaq directly if it will work you might have to update the bios.