curl-and-php
cURL can't resolve host through Apache/PHP, works with PHP/CLI
Date: Thu, 6 Sep 2007 23:41:59 +0200
Hi List,
I'm running my own webserver with FreeBSD 6.1, Apache 2.2.4, PHP 5.2.3 and
cURL, here's info about cURL saxet from phpinfo().
libcurl/7.16.3 OpenSSL/0.9.7e zlib/1.2.2 c-ares/1.4.0 libidn/0.6.14
When i try to use cURL from PHP throug a website i get a error 6 Can't
resolve host.
I have made this little test script that i use.
<?php
echo 'gethostbyaddr:' . gethostbyaddr($_SERVER['REMOTE_ADDR']) . '<br>;
echo 'gethostbyname:' . gethostbyname('www.bipbip.dk') . '<br>';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.bipbip.dk");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
echo curl_errno($ch) . curl_error($ch);
curl_close($ch);
?>
The output to the browser is this;
gethostbyaddr:x1-6-00-13-d5-47-f8-70.k681.webspeed.dk
gethostbyname:62.242.228.11
6Could not resolve host: www.bipbip.dk (Error reading file)
If i run it in PHP CLI mode, with the following command, the output is the
desired html from http://www.bipbip.dk
# php -f /path/to/testscript.php
Best regards,
Philip
-- Jeg beskyttes af den gratis SPAMfighter til privatbrugere. Den har indtil videre sparet mig for at fa 14055 spam-mails. Betalende brugere far ikke denne besked i deres e-mails. Hent gratis SPAMfighter her: http://www.spamfighter.com/lda _______________________________________________ http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-phpReceived on 2007-09-06