Connect to MySQLi

Additionally fixes some bugs such as E_ERROR and some syntax errors.
Now spits out errors if PRODUCTION is toggled in the configuration.