Added Error Handling

The site will no longer crash when the database query fails.