Philip is Queen Elizabeth II's husband, he was admitted as a precautionary measure and is in good spirits, the palace said.
Philip, also known as the Duke of Edinburgh, is 96 and recently said he was stepping down from public events. He has suffered heart ailments in the past. The palace said the infection is related to a pre-existing condition.
The queen is due to outline the government's legislative agenda in her speech today, instead Prince Charles will attend in Philip's place.
The palace said Philip is being treated at the King Edward VII Hospital in London after being admitted on Tuesday night.