in reply to Capturing STDERR with -

Since you appear to be on UNIX or Linux, you should be able to do the following:
exec("/bin/sh", "-c", "/usr/sbin/nslookup -q=$query_type $input $names +erver 2>&1");
Of course, if your shell is not in /bin, use the correct path.

HTH, --traveler