If a car's gear shift gets stuck, the first thing to look at is the fuse that enables or disables the car's shifting function. Refer to the vehicle owner's manual to confirm if your car is equipped with this type of fuse. If it is, use the owner's manual to locate the fuse and check for yourself if the fuse is blown. Replace the fuse as necessary.
Check if your parking brake is engaged, as many modern vehicles have a sensor that disables shifting in case of an engaged parking brake. If the parking brake is stuck as well, pushing the vehicle forward a few inches may help make disengaging the parking brake easier, which may also help unlock the gear shift.
If your car has a gear shift sensor underneath the brake pedal, check if it is stuck and then apply a lubricant such as WD-40 as necessary. Loosening up the button may help it engage and in turn unlock the gear shift.
If the brake pedal button was indeed the cause of the problem, the lubricant provides only a temporary fix, and the button is likely to fail again in the future. Take the vehicle to an authorized mechanic to have the button replaced.
If none of these troubleshooting tips work, that's a sign that you have a bigger problem with your vehicle's transmission system. It may be time to take your vehicle to a transmission shop for evaluation and repair.