grazie, risolto, non so precisamente come, ma riscrivendo $where è andato tutto,boh...