Harry had seen Mr. Weasley getting attacked by the snake, which was real. However, word must have probably reached Voldemort about this and he must have become aware of his mind's connection with Harry's. He, therefore, used it to his advantage to create a false reality in his mind and to project it into Harry's, thereby luring him into the Department of Mysteries.