title: PHP: file_get_contents(): failed to open stream error - works on test XAMPP test server, not live
body: <p>I’m creating a PHP application that for a movie theater that, when accessed by a user, fetches an external XML document, saves it to our server. That XML file is then used to load the showtimes and other movie information. If the file on our server is older than 15 minutes, it’ll be overwritten, otherwise, it’ll load the existing one. I already pretty much finished the application, and it works perfect on my XAMPP test server, however it fails to work on the live server.</p>
  
  <p>The external XML file is located at this URL: <a href="http://45502.formovietickets.com:2235/showtimes.xml" rel="nofollow noreferrer">http://45502.formovietickets.com:2235/showtimes.xml</a>. Our server that I am trying to save the file to is on one of HostGator’s Linux-based servers. Using PHP’s curl functions, I have been able to successfully load the XML file on the XAMPP test server only. On the live server, it simply fails to connect.</p>
  
  <p>I feel like it might be an some sort of access restriction on the formovietickets.com server, but the people behind it insist there isn't any sort of restriction going on. Does anyone know a work around for this issue? </p>
  
  <pre><code>&lt;?php
  
  $url = 'http://45502.formovietickets.com:2235/showtimes.xml';
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  if(curl_exec($ch) === false) {
      echo 'Curl error: '.curl_error($ch);
  } else {
      echo 'Retrieved file with no errors!';
  }
  curl_close($ch);
  
  ?&gt;
  </code></pre>
  
  <p><strong>What Have I Tested?</strong></p>
  
  <ul>
  <li>I’ve tried transferring the php.ini file over from XAMPP to the live server and it still fails.</li>
  <li>I was able to successfully retrieve an XML file located on another external server.</li>
  <li>I’ve tested the code on a Windows-based server and the problem persists.</li>
  </ul>
  
  <p>NOTE: If you load the URL more than a couple times from the same IP address in less than 15 minutes, you’ll get an error saying “Too many requests from this IP address”. Just saying in case you try testing it out.</p>