What happens if an iPhone dies completely and the 2 year contract isn't up?

Do you have to pay for a new phone or do they give you a replacement?

The contract is meaningless. It's the warranty you need to check. If it ran out, then you're most likely stuck paying for a phone that's no good. You can try contacting them and asking, though. You never know unless you ask.

If it's in the first year or afterwards with the insurance, you can get it fixed (usually for a small fee).

If you can't/don't, you still have to continue with the contract until it's up, either using another phone, buying another one (not at the new-contract price you paid when you first got the phone), or without a phone attached to the line.