I installed a wordpress theme to my website but there was an error in the code which meant I could not use /wp-admin to set another theme for some reason. I then tried deleting the theme from wp-content but that didn't work. Where in all the wordpress files can I change the theme programatically?
You have to look in the file error_log.
Restore back your applied theme and check error_log for the possible error that is causing wordpress to die.
Or if you are unable to fix the error open database select the database wordpress is using (open wp-config.php for reference to database name)
Change the theme name in options table, that's it
come back to admin panel and it should be working