I had a 89 or 90 camry with a bright yellow brake light control box in the back that was bad. It would make the brake light switch go out under the pedal then same problem with the shifter..
I forget what it was called but it was bright yellow and the size of a pack of cigarettes..repeated havoc till I found that in the circuit and swapped it
I had this happen in the same gen Camry - a cold solder joint in the board of the 'brake light computer', high up inside the trunk on the left side. Once soldered, it worked fine again.
Colo Springs, CO