Custom post query error

get_posts() doesn’t accept posts as input, it only takes argument to query posts. So it’s useless and breaking step in your process. It should work if you throw get_posts() out.

See Displaying Posts Using a Custom Select Query in Codex for extensive writeup on custom queries.

PS your query is seriously insecure, you need to be escaping any untrusted inputs.