Results 1 to 2 of 2

Thread: PHP Document Root

  1. #1
    Guest

    Question PHP Document Root

    I just migrated my website from another host, and I'm having some trouble with PHP.

    I have this line in my index.php:
    PHP Code:
    require($_SERVER["DOCUMENT_ROOT"]."/template.php");
    This throws an error:
    Fatal error: require() [function.require]: Failed opening required '/var/www/html/template.php' (include_path='.:') in /membri/kendallfrey/index.php on line 12

    Using PHP, how can I access the root folder where my files are from any subfolder? $_SERVER["DOCUMENT_ROOT"] is normally supposed to do that, but it doesn't work here. I don't want to have to manually specify a relative path.

  2. #2
    Gianluca is offline Administrator
    Join Date
    Feb 2010
    Posts
    512

    Default

    kendallfrey:

    this unfortunately a know issue affecting Apache as the environment variable is not set correctly.

    You should force at the beginning of your scripts:

    $_SERVER["DOCUMENT_ROOT"] = "/membri/kendallfrey";

Tags for this Thread

Posting Permissions

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

SEO by vBSEO