SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast vivek94401's Avatar
    Join Date
    Dec 2004
    Location
    CA, USA
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Require some answers on require function

    Hi Folks,

    I always used following code to access my config.php file.

    require $_SERVER[DOCUMENT_ROOT]."/config.php";

    It works just fine. Only problem is I have 12 subdomains and these are growing. $_SERVER[DOCUMENT_ROOT] actually takes subdomain name and looks for config.php in there. I need to keep config.php in all subdomain directories. I want to avoid this.

    I want to point directly to "www.mydomain.com/config.php". If I change my password of mysql database, I will change just in this file, no need to change in all "subdomain.mydomain.com/config.php".

    Is there anyway to do this with require function? If not, is there any other function out there that could solve this problem?

    Thanks in advance
    Vivek

  2. #2
    *munch munch* killerkooki's Avatar
    Join Date
    Sep 2004
    Location
    Singapore
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perhaps you can put a small string manipulation code to strip out the subdomain parts and put the original location?
    Then again, that isn't much of an improvement from hard coding the path either.

    I don't think there is anyway to get by this problem through the require function either.

  3. #3
    SitePoint Addict
    Join Date
    Apr 2005
    Location
    San Diego, CA
    Posts
    205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Run phpinfo(); in your script and scroll down to php variables. Check for any variables or combination of variables that already contain what you're looking for. For instance you might be able to use $_SERVER[HOST] and part of $_SERVER[DOCUMENT_ROOT].

    If you don't see what you need then you'll need to do some directory trickery yourself. Let us know. I do some domain and directory tricks that allows unlimited domains to use the same scripts but still have their own working directories.
    I study speed waiting. I can wait an entire hour in 10 minutes.


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
  •