Fixed wrong column names and added better mysql error handling