Are you sure you did not enter an incorrect TLD? (typed it wrong i mean)
I get that error when i put in "google.zing" for example.
(that would be my suggestion Dan, check if the extension is in the list

)
edit: suggestion 2: use strtolower to on the extension, as you can see if you enter .COM then it will throw the error as array keys are case sensitive.