I moved the search code to that position because as soon as I place it at line 121 I get the following error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0=0' at line 1.
Whats going wrong here?