Use single quotes ('attribute') for variable in function.
That just produces the literal variable - it doesn't cause a substitution of the variable's value into the query. And if the position of usage does need a column identifier it still will produce a syntax error.
But the error fragment shown suggests that the query shouldn't be expecting a column name (contrary to my earlier point), so we are back to having to see the entire function definition (or a reproducible example) to provide an answer. Spelling typo comes to mind.