I'd agree that the transmisson is likely so I'd take a look at the colour of the transmission oil it should be a dark red colour if its black then its needs changing together with its oil filter. Also check its level with the gearbox warm and just after you've moved the selector through all the positions leaving it for a few seconds in each one and then back to park.
You can top up the box through the dipstick tube if required and make sure you use the correct oil for your car as the fluids are not all the same. Some manufacturers recommended a change of the type of fluid - Speak to the local dealer and parts dept - they will advise you on the updated fluid to use..
If that’s all OK then check all the electrical connections of the gearbox, remove each connector in turn and spray with contact cleaner. Check that the wiring to the gearbox is in good condition with no chafing or frayed wire
If this is OK then check the selector lever linkage / cable under the car for any broken parts and or missing bolts as if this is coming adrift then it can rub on the car body or just bind up
Then - you should top up if low and re try it - or, if its level is ok - and condition is ok - then the next step is to drain it off - open it up and clean the filters inside -- refill and retry it..
( 13-15Kohm / metre) and replace if any doubt or high resistance - Also replace the spark plugs if any of them fail this checklist:
Also its worth checking that the electric pump that feeds the injectors is working correctly, it should run for a few seconds then switch off when you first turn the ignition on. If the connections to this are corroded or damaged then the pump could stop at any time. Check that its relay switches in and out and the relay contacts are clean and bright – replace the relay if in any doubt and do the same for the fuse, ideally measure the voltage at the pump and check its getting 12V