Unfortunately, after removing PDO and its prepared statements, and using addslashes of all things, you're back to code that is thirteen years out of date.
I don't know what issues you were having with the other code, but I guarantee it wasn't PDO and using prepared statements to protect your database.
It's difficult for me to continue trying to help you. It seems like things keep regressing, you run into a minor problem like a missing character and throw everything out and come back with something worse with an entirely new set of problems. The unfortunate thing is that I doubt that you understand this code any better than the code you threw out. Maybe I'm wrong, but when it's telling you which line the error is on and you can't spot things like a missing semicolon or hanging comma it seems like you're not understanding what you're doing. Tossing out newer code and trying to go back to something that people stopped using a decade ago isn't helping.