You are using single-quotes around this string, so the php variables are NOT being replaced with their value. Use double-quotes.
When you make the connection, you should also set the emulated prepared query setting to false, you want to run real prepared queries whenever possible, and set the default fetch mode to assoc, so that you don’t need to specify it in each fetch statement.
There’s no good reason to catch and handle a connection error in your code. Remove the try/catch logic and let php catch and handle any connection error. The only database errors you should catch and handle in your code are for user recoverable errors, such as when inserting/updating duplicate user submitted data.