PHP read web page contents

I've been trying to read the contents from a particular URL into a string in PHP, and can't get it to work.  I've tried the Request.PHP PEAR module, the cURL methods, and the standard file_get_contents() function, but no matter what I do, I can't seem to get anything.

I'm running PHP 5 w/ IIS 6 on a Win2k3 server.  The URL I'm trying to read responds with an XML fragment, based on some query data I send to it.  There URL changes based on the query data, but when I output the URL from my script into a link and click it, I get the XML fragment returned to my browser with no trouble.  So I know that the URL I'm trying to pass to the various methods is indeed valid and will indeed respond with an XML fragment.

Again, when I try to get the same fragment into a from within my PHP script (using the URL from a string variable) into a string, I get nothing.  I've tried code that apparently works on an Apache server (using the Request.PHP module), but nothing I try gets anything.  I've used all kinds of var_dumps to see what's going on, and everything looks like it checks out, but nothing ever comes through into the string.

Can anyone think of what the problem might be?  I'm really struggling here and cannot for the life of me figure out what the problem is.  I've got another question on here with a title like PHP / CAS question that has more information.  I've been screwing with this for over a week now and I need to figure it out.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

whats the url your trying to get. If we can retrieve it ok, then we can offer a solution that should work for you. (win200, apache 2, mysql 4)

p.s. I luv curl.
well here is a piece of code that I have used to read parts of other pages.  maybe it will help

<form action="harvester.php" method="post">
      Read from site:<input type="text" value="" name="address"><br>
      Start at word:<input type="text" value="" name="start"><br>
      End at word:<input type="text" value="" name="stop"><br>
      <input type="submit" value="submit" name="submit">

if($submit) {       

      $handle = fopen($address, "r"); // point stream to site
      while (!feof($handle)) {
            $contents .= fread($handle, 8192); // read site into buffer
      echo "searching site: " . $address ."<br>";

      // pick word to start reading from
      $start_pos = strpos($contents, $start);  // find position of that word
      echo "Starting at: " . $start . "<br>found at location: " . $start_pos . "<br>";

      $first_trim = substr($contents, $start_pos);

      // pick word to stop reading at
      $stop_pos = strpos($first_trim, $stop);  // find position of that word
      echo "Stoping at: " . $stop . "<br>found at location: " . $stop_pos . "<br>";

      // cut the string before and after selected words
      $second_trim = substr($first_trim, 0, $stop_pos);

      echo "<p>" . $second_trim;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
I guess the problem in W2K3. You have to check security settings, because it can block attempts of your scripts to connect somewhere outside. You can try to read contents of web page located on the same server, for example trya to recieve with "http://localhost/getcontent.php" a content of "http://localhost/sample.php" and if so, then do something with security of OS :))
Zeek0Author Commented:
I figured out that the problem was, in fact, with IIS 6.  The application pooling doesn't allow sockets to be created, let alone opened and used to transfer data.  Lord only knows why, but I got the script I had to work when I set the application pooling to "IIS Isolation Mode" and chose "Low (IIS Process)" for the 'application protection' setting.  

I don't know why I had to change those settings, but they made my script work.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.