Fixed PHP Warnings

Was getting a few php warnings for undefined variables. Added some conditional checks and defined some vars. On my tests, it didn't affect the search results.