Announcement

Collapse
No announcement yet.

fopen through http

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • fopen through http

    Hey all:

    PHP Code:

    $whofile 
    = @fopen ("http://someserver.com/~version2/who.txt""r");



      if(
    $whofile)

      {

        
    $wholine fgets($whofile4096);

        
    fclose ($whofile);

        
    $whoarray explode(" "$wholine);

        
    $totalircusers count($whoarray);

      

        for(
    $x=0$x $totalircusers$x++)

        {                             

          if(
    $x == $totalircusers 1)

          {

            
    $ircusers .= $whoarray[$x];

          }

          else

          {

            
    $ircusers .= $whoarray[$x] . ", ";

          }

        }

      } 
    Ok, my question is this...if the text file on the other server cannot be reached for some reason then it makes the whole page fail to load.

    Is there anyway to safegaurd against this? Meaning...if there is a network problem and the file is unreachable then just print N/A or something like that or at least just continue to load the rest of the page?
    version2 aka mol

    Mystic Wicks Online Pagan Community Forums
    Mystic Wicks After Dark

  • #2
    well you started it. the if statemnet is the start. you just need to include an else with that and then load the rest of the page.

    or use file_exist($whofile)

    Comment

    widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
    Working...
    X