Then the king Nebuchadnezzar fell upon his face, and worshipped
Daniel, and commanded that they should offer an oblation and sweet
odours unto him. (Daniel 2:46, KJV)
The translation is inaccurate, unfortunately. The Hebrew does not actually say the king worshipped Daniel. It says the king worshipped in front of or before Daniel. Obviously, that can be taken to mean that he worshipped Daniel--as some translations have rendered it; but that is hardly the only way it can be taken, and, in any case, that is not the way it is worded.
The king was intelligent. He knew that the wisdom he had been given through Daniel was of no mortal origin. At threat of death to themselves and their families, none of the scholars or counselors of the king had been able to tell him what he had dreamed. And how could they? As they had told the king, "it is a rare thing that the king requireth, and there is none other that can shew it before the king, except the gods, whose dwelling is not with flesh" (vs. 11).
The next verse tells us Whom Nebuchadnezzar was really worshipping.
The king answered unto Daniel, and said, Of a truth it is, that your
God is a God of gods, and a Lord of kings, and a revealer of secrets,
seeing thou couldest reveal this secret. (Daniel 2:47, KJV)
In awe, Nebuchadnezzar had fallen prostrate at Daniel's feet and humbly worshipped. Daniel must have recognized the true object of this worship, and knew that it was not himself. The king's words confirm this. He was worshipping Daniel's God.