Reply to Curl fails with Apache - but works in Command Line

Your name:

Reply:


Posted by BinnyVA on 11/05/06 18:25

Hi,
I am using PHP 5.1.2 with curl enabled. But whenever I try to use curl
to fetch a url, it fails - 'curl_exec()' returns nothing.

But if I try to execute the same file in CLI - like 'php curl.php', the
script works properly. However if I try it in a browser, nothing is
returned.

The code is...

curl.php
----
<?php
$ch = curl_init("http://localhost/");
curl_setopt($ch, CURLOPT_URL, "http://localhost/data.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //Just return the data
- not print the whole thing.
curl_setopt($ch, CURLOPT_HEADER, false); //We need the headers
curl_setopt($ch, CURLOPT_NOBODY, false); //The content - if true, will
not download the contents
print curl_exec($ch);
curl_close($ch);
----

--
Binny V A
http://www.bin-co.com/php/

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация