file which tries to find itself and can't...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • julian_m

    file which tries to find itself and can't...

    <?
    //file test.php
    phpinfo();

    $filename = "test.php"; //it does not work

    $filename =
    $_SERVER['DOCUMENT_ROOT']."/home/ke000067/public_html/test.php"; //it
    does not work

    $filename =
    $_SERVER['DOCUMENT_ROOT']."/~ke000067/public_html/test.php"; //it
    does not work

    $filename = "home/ke000067/public_html/test.php"; //it does not
    work

    echo 'fila buscada: '.$filename.'<b r>';

    if (file_exists($f ilename)) {
    echo 'Of course it is.<br>';
    }else{
    echo 'What?? How can it be???.<br>';
    }

    ?>


    these are some values retieved from phpinfo
    _ENV["REMOTE_POR T"] 2010
    _ENV["SCRIPT_FILENAM E"] /home/ke000067/public_html/test.php
    _ENV["SCRIPT_URI "] http://200.50.110.233/~ke000067/test.php
    _ENV["SCRIPT_URL "] /~ke000067/test.php
    _ENV["SERVER_ADD R"] 200.50.110.233
    _ENV["SERVER_NAM E"] 200.50.110.233
    _ENV["SERVER_POR T"] 80
    _ENV["SERVER_SIGNATU RE"] <ADDRESS>Apac he/1.3.33 Server at
    200.58.112.233 Port 80</ADDRESS>
    _ENV["SERVER_SOFTWAR E"] Apache/1.3.33 (Unix) mod_auth_passth rough/1.8
    mod_bwlimited/1.4 mod_log_bytes/1.2 mod_ssl/2.8.22 OpenSSL/0.9.7e
    FrontPage/5.0.2.2635
    _ENV["GATEWAY_INTERF ACE"] CGI/1.1
    _ENV["SERVER_PROTOCO L"] HTTP/1.1
    _ENV["REQUEST_METHOD "] GET
    _ENV["REQUEST_UR I"] /~ke000067/test.php
    _ENV["SCRIPT_NAM E"] /~ke000067/test.php
    _ENV["PATH_TRANSLATE D"] /home/ke000067/public_html/test.php


    I'm really confused about paths. Now I think that it is not a good idea
    to learn on local server, beacause whenever one changes to a shared
    one, all seems to fail....

    Any hints?

    sdos - jm

  • Csaba Gabor

    #2
    Re: file which tries to find itself and can't...

    To show the current file:
    <?php print __FILE__ ?>

    Csaba Gabor from Vienna

    Comment

    • julian_m

      #3
      Re: file which tries to find itself and can't...


      Csaba Gabor wrote:[color=blue]
      > To show the current file:
      > <?php print __FILE__ ?>[/color]


      I don't understand what are you trying to say. I was asking about how
      can it be possible that file_exist didn't find a file which obviously
      exists. I cant figure out where the error is; thats all...

      regards - jm

      Comment

      • kay

        #4
        Re: file which tries to find itself and can't...

        if the file is in the same directory as script.... then..

        <?php
        if(file_exists( "test.php"))pri nt("file is here!");
        ?>

        MUST work :-)

        Comment

        • julian_m

          #5
          Re: file which tries to find itself and can't...


          kay wrote:[color=blue]
          > if the file is in the same directory as script.... then..
          >
          > <?php
          > if(file_exists( "test.php"))pri nt("file is here!");
          > ?>
          >
          > MUST work :-)[/color]

          Well, I think my ISP has any kind of weird php.ini file which prevents
          even the basic things like file_exists



          <?PHP
          if(file_exists( "myself.php ")){

          print("file is here!");

          }else{
          print ("Incredible :(");
          }

          ?>

          I cant believe ;(

          regards - jm

          Comment

          • Jerry Stuckle

            #6
            Re: file which tries to find itself and can't...

            julian_m wrote:[color=blue]
            > <?
            > //file test.php
            > phpinfo();
            >
            > $filename = "test.php"; //it does not work
            >
            > $filename =
            > $_SERVER['DOCUMENT_ROOT']."/home/ke000067/public_html/test.php"; //it
            > does not work
            >
            > $filename =
            > $_SERVER['DOCUMENT_ROOT']."/~ke000067/public_html/test.php"; //it
            > does not work
            >
            > $filename = "home/ke000067/public_html/test.php"; //it does not
            > work
            >
            > echo 'fila buscada: '.$filename.'<b r>';
            >
            > if (file_exists($f ilename)) {
            > echo 'Of course it is.<br>';
            > }else{
            > echo 'What?? How can it be???.<br>';
            > }
            >
            > ?>
            >
            >
            > these are some values retieved from phpinfo
            > _ENV["REMOTE_POR T"] 2010
            > _ENV["SCRIPT_FILENAM E"] /home/ke000067/public_html/test.php
            > _ENV["SCRIPT_URI "] http://200.50.110.233/~ke000067/test.php
            > _ENV["SCRIPT_URL "] /~ke000067/test.php
            > _ENV["SERVER_ADD R"] 200.50.110.233
            > _ENV["SERVER_NAM E"] 200.50.110.233
            > _ENV["SERVER_POR T"] 80
            > _ENV["SERVER_SIGNATU RE"] <ADDRESS>Apac he/1.3.33 Server at
            > 200.58.112.233 Port 80</ADDRESS>
            > _ENV["SERVER_SOFTWAR E"] Apache/1.3.33 (Unix) mod_auth_passth rough/1.8
            > mod_bwlimited/1.4 mod_log_bytes/1.2 mod_ssl/2.8.22 OpenSSL/0.9.7e
            > FrontPage/5.0.2.2635
            > _ENV["GATEWAY_INTERF ACE"] CGI/1.1
            > _ENV["SERVER_PROTOCO L"] HTTP/1.1
            > _ENV["REQUEST_METHOD "] GET
            > _ENV["REQUEST_UR I"] /~ke000067/test.php
            > _ENV["SCRIPT_NAM E"] /~ke000067/test.php
            > _ENV["PATH_TRANSLATE D"] /home/ke000067/public_html/test.php
            >
            >
            > I'm really confused about paths. Now I think that it is not a good idea
            > to learn on local server, beacause whenever one changes to a shared
            > one, all seems to fail....
            >
            > Any hints?
            >
            > sdos - jm
            >[/color]

            Julian,

            It should work if you either use relative addressing ("test.php") or
            absolute addressing from the web server's root directory
            ($_SERVER['DOCUMENT_ROOT'] . "/test.php") assuming test.php is in the
            root directory.

            I develop a lot of scripts on my local machine and upload them with no
            problems.

            The fact you're having problems with such a basic function indicates to
            me your hosting service has something set up incorrectly.


            --
            =============== ===
            Remove the "x" from my email address
            Jerry Stuckle
            JDS Computer Training Corp.
            jstucklex@attgl obal.net
            =============== ===

            Comment

            Working...