Can I unlock my old iPhone from AT&T or does the phone have to be active?

I applied with AT&T to get my iPhone 4 unlocked and it was accepted but I'm using my new phone now.

Can I still unlock it even though it us inactive?

Added (1). This is a legit AT&T unlock that us done through iTunes.

I'm just not sure how it works with an inactive phone

Yes, but you probably need a SIM card from another carrier to apply the unlock code. You insert the foreign SIM, and enter the unlock code when you power up the device.

This is how it works on most phones, so I assume the iPhone works the same way.