Hi, I had same problem with my 2002 e46 320d, key just died without warning one day, here is how I got it working again.

1. Get in car, close doors.
2. Put key in ignition and switch it to position 2 two times
3. Take key out and keep holding "open button, arrow up" down and press lock button (middle one) three times
4. Doors should lock now and open again

I guess in my case battery was drained for some reason and it lost memory, after I took it for a longer spin to recharge battery and did the above key is working again.