motor shuts off when put in gear on 1997 Nissan Maxima

The car starts and idles just fine, but when i shift into drive or reverse it kills the motor. Sometimes it doesn't . Please explain my problem

Asked by for the 1997 Nissan Maxima
I have seen a lot of Maximas with bad front engine mounts, when the mount wears the engine lifts when put in drive and can damage the ir induction boot to the air flow meter. There were some Maximas around that time that had bad wiring harnesses at the right side of the engine compartment that caused drivability problems and set false codes. Its foolish to speculate basic diagnostic tests need to be performed to see what the real cause of the stalling is.
1 more answer
1997 nissan maxima motor shuts off in reverse