I don't see where the problem is, but I can try to help you narrow it down.
There are 4 recordsets on your page... this error is coming from when one of those queries is running on one of the lines that ends in:
die(); will stop the code processing at that point and write whatever string is passed to it. In this case it is writing the error string.
What you can do, is add code before each line that has that code like:
echo("Recordset 1 ");
and write before the second time the die() appears:
echo("Recordset 2 ");
and do the same for the third and fourth.
Then when you view the page again it will look something like:
Recordset 1 Recordset 2 Recordset 3 Unknown column '1' in where clause
This would narrow down that the error was in the third recordset.
Then you could remove all of your echo statements since you have narrowed it down and in place of the last echo statement you saw, add a die statement with the sql... so if it was recordset 3 you would replace it with:
This would write the full sql statement to the page that is being run. That should allow you to see what might be the problem with that sql statement and fix it.
If you get that far and can't spot the issue, try taking that sql statement into phpMyadmin and debug it in the Query window there... you can also post it back here and I might be able to spot the problem.