Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 8 of 8
  1. #1
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default If file exisits display it, if it doesn't then don't

    I know how to do this on the same server, how how do you open it from another server?

    I have tried fopen(), file_exists() and file(). None of them seam to have worked.

    They all still opened the file even if it didn't exisit.

    The reason I need it to not open it is because I need it to enter the ones which do exist into a database.

  2. #2
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    Hi, names James. I am a web developer.

  3. #3
    Join Date
    Mar 2008
    Location
    England, Cheshire.
    Posts
    173
    Tokens
    0

    Default

    <?php

    (@file_get_contents("http://URL_TO_FILE.URL/TO/FILE.TXT"))
    {
    // Put the stuff you want to show if the file was found here
    }
    else
    {
    //Put the stuff you want to show if the file was not found here!
    }

    ?>

    Hope it helps

  4. #4
    Join Date
    Apr 2005
    Posts
    4,614
    Tokens
    90

    Latest Awards:

    Default

    PHP Code:
    <?php
    $page 
    $_GET["page"];
    if(
    file_exists($page)) {
    include(
    "$page");
    } else {
    echo(
    "Page doesn't exist");
    }
    ?>

  5. #5
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Just thought I would expand on Robbie!'s:

    PHP Code:
    <?php

    $file 
    "test.php"// you can enter a path here aswell ex: /home/test/public_html/test.php

    if(!file_exists($file)) {
        exit(
    "404. File not found!"); // if the file isn't found, display this error.
    } else {
        include(
    $file); // display the file.
    }

    ?>

  6. #6
    Join Date
    Sep 2006
    Location
    Evanston, Illinois.
    Posts
    2,361
    Tokens
    0

    Latest Awards:

    Default

    Expanding? You've added a comment, and got rid of a $_GET[]...contracting more like it.
    How could this hapen to meeeeeeeeeeeeeee?lol.

  7. #7
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default

    None of these work for remote files. Thanks for the help though

  8. #8
    Join Date
    Apr 2005
    Posts
    4,614
    Tokens
    90

    Latest Awards:

    Default

    PHP Code:
    <?php
    if(file_get_contents("http://google.co.uk")) {
    echo(
    "The page exists!");
    } else {
    echo(
    "The page does not exist!");
    }
    ?>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •