Creating custom subpanel on Users module

SQL errors are usually more explicit than that, they tell you exactly what is wrong…

Try printing your $query variable to check if the quotes and variable substitution are working as intended.