La stringa "Resource id #4...." è dovuta all'echo prima del while.