You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND bloqueado = 0 AND '2013-10-02 08:46:45' BETWEEN dinicio AND dfim order by or' at line 1