The variable $type really is $dataformat. I have changed it for prevent the error and show a correct error message.