i understand that, the code i provided will output the SQL being run to the page, If i can see the SQL that is being executed, It may help me understand what the problem is.
It looks like you have not added the code correctly to the results page it is only outputting ") ?>
if it is properly added to the results page, it will show the SQL being executed.