Improved MySQL error handling and added error message shown to user