Results 1 to 4 of 4

Thread: PHP - Includes Failing

  1. #1
    Join Date
    Dec 2007
    Beans
    7

    Virtual Hosts - PHP - Includes Failing

    I have set up Apache, so that rather than /var/www being the site, /home/adam/public_html is. I then disabeled the /var/www as default site, and enabled the second /home path as the site called 'adam'. Everything was hunky dorey, and is running, but all of my PHP includes in my applications fail.
    This is the specific error:
    Code:
    Warning: require_once(../sb-includes/config.php) [function.require-once]: failed to open stream: No such file or directory in /home/adam/public_html/simplyblog2/sb-classes/config.php on line 2
    
    Fatal error: require_once() [function.require]: Failed opening required '../sb-includes/config.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/adam/public_html/simplyblog2/sb-classes/config.php on line 2
    I know for a fact that all the files exist that are being referenced though! Sorry if this is a common problem, but it's just a little annoying as I thought I had everything set up!
    Last edited by adamcoppard; February 1st, 2009 at 02:01 PM. Reason: Change of title, to make more suitable

  2. #2
    Join Date
    Dec 2007
    Beans
    7

    Re: PHP - Includes Failing

    That was a bit of a bad description, and the problem now only presents itself whenever using ../ to go up one directory. I can do this:
    PHP Code:
    require 'config.php'
    This:
    PHP Code:
    require 'sb-classes/config.php'
    But not:
    PHP Code:
    require '../sb-includes/config.php'
    It only presents itself when using the host method outlined above (the method above DOES NOT use userdir method, just twisting and changing apache2.conf in /etc/apache2/apache2.conf)

    Thanks,

  3. #3
    Join Date
    Dec 2007
    Beans
    7

    Re: PHP - Includes Failing

    Now, why this is failing is very beyond me! It even fails with the default configuration, and doing ../test.php will work, where as ../sb-includes/config.php won't!

  4. #4
    Join Date
    Jan 2007
    Beans
    33
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: PHP - Includes Failing

    I always use the following for includes:

    PHP Code:
    include($_SERVER['DOCUMENT_ROOT']."/dir/filename.php"
    Or something like that.
    That way, it always goes to the root directory of your site (thus public/html/ or something like that)
    And after that, you locate the file from that root directory. (note the first /!)

    that way has never failed me...
    Casa Laguna, the world from a students point of view
    P.s.
    My avatar is a scan of my brain. The moth next to my brain is Bart. Please say hi to him if you like? He's kinda lonely.

Tags for this Thread

Bookmarks

Posting Permissions

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