Prova a stampare $query e poi eseguirla manualmente.

Una dritta apici