title: PHP fopen() Redirection Limit Reached Error
body: <p>When executing the following block of code:</p>
  
  <pre><code>foreach($eventfiles as $eventfile)
  {
      if($eventfile['filename'])
      { 
          $file = $eventfile['filepath'];
          // Open File
          if( !($fp = fopen($file, "r")))
          {
              echo '&lt;br&gt;CAN NOT READ FILE.';
              exit;
          }
          // Read data from the file into $data
          $data = "";
          while (!feof($fp)) $data .= fread($fp,1024);
          query("update event_rtab set html = '".escape($data)."' where id = {$eventfile[id]}");
      }
      if($eventfile['eventType']=='email')
      {
          query("INSERT INTO event_email_rtab (event_id,subject) values ($eventfile[id],'".escape($eventfile[email_subject])."')");
      }
  }
  </code></pre>
  
  <p>The script fails with the following error: </p>
  
  <blockquote>
    <p>fopen(test.html)
    [function.fopen]: failed to open
    stream: Redirection limit reached,
    aborting in
    /data/www/example.com/public/test.php
    on line 843</p>
  </blockquote>
  
  <p>What causes this error and how can I correct it?</p>