i just discovered my 1999 bmw e46 has a tear and crack on intake boot and engine stalls when you start it and eventually switches off but when i disconnect air flow sensor it works perfectly
Replace the boots and clean the MAF and see if things improve. Do you have a CEL on?
Disconnecting the MAF causes the ECU to use the TPS and default fuel maps. These maps are defaulted to enriching the air/fuel mixture and that's why things work better. Vacuum leaks, aka ripped hoses after the MAF will make your car run terrible.
In my BMW Z4 that I used to own...even a miss-installed oil fill cap will make the cel light come on and the idle very rough. These cars are very sensitive to un-metered air leaks.
Looking for a Used 3 Series in your area?
CarGurus has 35,653 nationwide 3 Series listings starting at $900.
Search BMW 3 Series Questions
BMW 3 Series Experts