SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    I want my 4th arrow! garlinto's Avatar
    Join Date
    Jun 2002
    Location
    Riding the electron wave
    Posts
    372
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    include path problem

    I'm having a very frustrating include() path problem.

    When I do this:
    PHP Code:
    include 'config.php'
    , I don't have a problem.
    But when I try:
    PHP Code:
    include '../config.php'
    , I can't get it to work. The error I get is:
    Warning: Failed opening '../config.php' for inclusion (include_path='.:/usr/share/pear') in /home/tandr/tandrtrailer.com/htdocs/ads/rotate.php on line 3
    Error 1:You have an error in your SQL syntax near '' at line 1
    I wanted to put my 'config.php' file in my cgi-bin so that it would be in a central location for my other scripts. I've done a search to learn about include paths here at sitepoint and learned a lot, but I still can't get it to work.

    I'm sure the solution is very simple.
    Ducharme's Axiom: "If you view your problem closely
    enough, you will recognize yourself as part of the problem."


  2. #2
    SitePoint Addict
    Join Date
    Oct 2003
    Location
    United States
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you tried something along the lines of /cgi-bin/config.php ?

  3. #3
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    ini_set('include_path'ini_get('include_path').':/path/to/the/dir/config/will/be/in');
    //this should allow you to include config.php from anywhere
    include_once 'config.php'

  4. #4
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What your basically doing is that you want to INCLUDE your config file which resides one directory up from where this PHP script actually is.

    Your CGI [I do not have CGI] from what I remember is on the root directory of your PHP installation; ie Same directory level as HTDOCS isn't it not ?

    So the directory path that you've choosen is wrong no in any event, if on the otherhand your CGI directory is one directory up from where you've put your script, then try this...

    PHP Code:
    ../cgi/config.php 
    To see if that helps... If CGI is one directory up from where you've saved your script that is

  5. #5
    I want my 4th arrow! garlinto's Avatar
    Join Date
    Jun 2002
    Location
    Riding the electron wave
    Posts
    372
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys!
    And thanks mark999 for the code snippet. I was actually doing some research to come up with code that would perform that same function! Thanks.
    Ducharme's Axiom: "If you view your problem closely
    enough, you will recognize yourself as part of the problem."


  6. #6
    I want my 4th arrow! garlinto's Avatar
    Join Date
    Jun 2002
    Location
    Riding the electron wave
    Posts
    372
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok...mark999:
    I have this:
    PHP Code:
     ini_set('include_path'ini_get('include_path').':/path/to/the/dir/config/will/be/in'); 
    I've tried a number of combinations but I can'y seem to get it right. The /path/to/the/dir/config/will/be/in/ is relative to what?

    Do I write:
    PHP Code:
    ini_set('include_path'ini_get('include_path').':/mysite.com/cgi-bin/php/');
    // which is where the file is, actually 
    ...or what, exactly?

    Sorry I'm so dense
    Ducharme's Axiom: "If you view your problem closely
    enough, you will recognize yourself as part of the problem."


  7. #7
    SitePoint Guru
    Join Date
    Aug 2001
    Location
    Amsterdam
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    put this in your .htaccess file (in the root folder)

    Code:
    php_value include_path /home/tandr/tandrtrailer.com/htdocs/cgi-bin
    if there isnīt a .htaccess file just make a new file and call it .htaccess and put this line in...
    the neigbours (free) WIFI makes it just a little more fun

  8. #8
    I want my 4th arrow! garlinto's Avatar
    Join Date
    Jun 2002
    Location
    Riding the electron wave
    Posts
    372
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    this did it...

    This finally did it:
    PHP Code:
    ini_set('include_path'ini_get('include_path').':/home/tandr/tandrtrailer.com/cgi-bin/php');
    include_once 
    'config.php'
    Thanks for all of the help
    Ducharme's Axiom: "If you view your problem closely
    enough, you will recognize yourself as part of the problem."



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
  •