require_once fails with file in same directory

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

    require_once fails with file in same directory

    Has anyone come across this problem with require_once?

    I was working on my local machine with apache and have included a file
    like this:

    require_once "welcome_patien t.php";

    Works fine, the file that "requires" this is in the same directory

    /
    /sections <- both file and required file in here
    /images

    On our live server, the require_once fails every time, include path
    says: include_path='. :./includes:/usr/share/pear:'

    Strange thing is, if I change require_once to include_once it works fine
    but I'd prefer the script to fall over if it doesn't find the include.

    Thanks in advance.

    PS. Only other difference between servers is my local machine is Windows
    and live is Linux, but I checked the include path delimiters were correct.

  • bill

    #2
    Re: require_once fails with file in same directory

    Tyno Gendo wrote:
    Has anyone come across this problem with require_once?
    >
    I was working on my local machine with apache and have included a file
    like this:
    >
    require_once "welcome_patien t.php";
    >
    Works fine, the file that "requires" this is in the same directory
    >
    /
    /sections <- both file and required file in here
    /images
    >
    On our live server, the require_once fails every time, include path
    says: include_path='. :./includes:/usr/share/pear:'
    >
    Strange thing is, if I change require_once to include_once it works fine
    but I'd prefer the script to fall over if it doesn't find the include.
    >
    Thanks in advance.
    >
    PS. Only other difference between servers is my local machine is Windows
    and live is Linux, but I checked the include path delimiters were correct.
    >
    what happens when you have
    require_once "./welcome_patient .php";

    Comment

    • Edward Z. Yang

      #3
      Re: require_once fails with file in same directory

      -----BEGIN PGP SIGNED MESSAGE-----
      Hash: SHA1

      Tyno Gendo wrote:
      Has anyone come across this problem with require_once? [snip]
      It's quite puzzling. The PHP manual states that are identical in every
      way, so I'm inclined to distrust your testimony.

      Some possible fixes:
      - - Change the ./includes entry to a fully qualified absolute path

      Some definitely will work fixes:
      - - Use require_once(di rname(__FILE__) . '/welcome_patient .php');

      - --
      Edward Z. Yang GnuPG: 0x869C48DA
      HTML Purifier <htmlpurifier.o rg Anti-XSS HTML Filter
      [[ 3FA8 E9A9 7385 B691 A6FC B3CB A933 BE7D 869C 48DA ]]
      -----BEGIN PGP SIGNATURE-----
      Version: GnuPG v1.4.6 (MingW32)
      Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

      iD4DBQFGU0F0qTO +fYacSNoRAu/4AJYmjN21ALqqHy nEs89RbTuo4kN6A J9FeUO9
      Ouvw3loD4zKUyJI eUkq1ew==
      =oTjI
      -----END PGP SIGNATURE-----

      Comment

      • Tyno Gendo

        #4
        Re: require_once fails with file in same directory

        Edward Z. Yang wrote:
        -----BEGIN PGP SIGNED MESSAGE-----
        Hash: SHA1
        >
        Tyno Gendo wrote:
        >Has anyone come across this problem with require_once? [snip]
        >
        It's quite puzzling. The PHP manual states that are identical in every
        way, so I'm inclined to distrust your testimony.
        >
        Some possible fixes:
        - - Change the ./includes entry to a fully qualified absolute path
        >
        Some definitely will work fixes:
        - - Use require_once(di rname(__FILE__) . '/welcome_patient .php');
        >
        - --
        Edward Z. Yang GnuPG: 0x869C48DA
        HTML Purifier <htmlpurifier.o rg Anti-XSS HTML Filter
        [[ 3FA8 E9A9 7385 B691 A6FC B3CB A933 BE7D 869C 48DA ]]
        -----BEGIN PGP SIGNATURE-----
        Version: GnuPG v1.4.6 (MingW32)
        Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
        >
        iD4DBQFGU0F0qTO +fYacSNoRAu/4AJYmjN21ALqqHy nEs89RbTuo4kN6A J9FeUO9
        Ouvw3loD4zKUyJI eUkq1ew==
        =oTjI
        -----END PGP SIGNATURE-----
        you were correct to distrust me, i lied and include_once wasn't actually
        working either LOL, if i did this it worked on the live server and on
        the internal machine... in the end the following seemed fine

        require_once getcwd() . '/sections/template.tpl';

        Comment

        Working...