When using checkdnsrr I get an Internal Server error.

I am using PHP RPM on IBM i.

Has anyone seen this error and could give me information on how to address it?

<?php
$domain="w3schools.com";
if(checkdnsrr($domain,"MX")) {
  echo "Passed";
} else {
  echo "Failed";
}
?>

Error received when running scrip:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Contact the server administrator at [no address given] to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.

Error Log:
[Fri Apr 09 09:11:14.699000 2021] [zend_enabler:error] [pid 8012:tid 00000033] Can not read response from /QOpenSys/pkgs/bin/php-cgi (0.0) - [0] There is no error.

Time to try other PHP or check configuration. Why? I tried that on a few online PHP sites and got this:
"Warning: gethostbyname() has been disabled for security reasons"

That appears to be happening to you. I am not conversant with your choice of PHP or server.

As rproffitt suggets, it's possible that the version of PHP you're running does not allow checkdnsrr(). Are you running PHP on a Windows web server or Linux? Do other network-related PHP functions work?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.