1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

help required using include()

Discussion in 'PHP' started by hawkoftheeye, Jun 4, 2008.

  1. X.Homer.X

    X.Homer.X Peon

    Messages:
    290
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #21
    ... i know what the include is for css. i just didnt have it open and its in my file. i dont know it off by heart. btw ill try that ./config.php thanks.

    and with my css.css file it is in the root directory, and is being included by includes/top.php which is being included by admin/index.php

    it works on my regular page but not on my admin

    EDIT: got config working for admin directory, but now wont work for regular page. whetever ill just go back with 2 versions of each file, one for admin in root/admin/includes and one for regular in root/includes
     
    X.Homer.X, Jun 4, 2008 IP
  2. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #22
    Well if you post a mistake, that's what I got to go by. Everybody makes mistakes so I just pointed it out. Best hint to help with "finding" the missing admin CSS file is to use Firefox's developer's toolbar, CSS>View CSS, check the url it looks for and correct it from there. Could be a simple typo.
     
    shallowink, Jun 4, 2008 IP
  3. X.Homer.X

    X.Homer.X Peon

    Messages:
    290
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #23
    Everything is working now, (thanks for the help guys thought i already had a / before css) but now my config is looking for common.php in the wrong place. On the index it looks in the home/phpbb3 directory and on the admin index it looks in admin/phpbb3/ directory. if i change the config so it says phpbb3 is in "../phpbb3/ then it works for admin, and homepage is screwy. :p

    I may have to have seperate config files.
     
    X.Homer.X, Jun 5, 2008 IP
  4. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #24
    Could set a path variable to append to the include filename. Set the default for the main part of the site and override the variable for the admin section. Though using an admin conf file works too.
     
    shallowink, Jun 5, 2008 IP
  5. X.Homer.X

    X.Homer.X Peon

    Messages:
    290
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #25
    hm, thanks for that idea, ill try it.

    how would i go about doing this? my top.php file is the same file being included in both root/index.php and root/admin/index.php so i cant simply set a variable in that file because the variable will also happen in my admin directory, which is wrong. If i put the variable before the top.php script, top.php just overwrites it. If i put it after, config doesnt know where to include from. is there any way to get the url name so that i can be like

    
    if ($url[10] = admin)//if the tenth character of the url and later is admin (im not sure of the code, dont quote me on this)
      {
    $incpath = "../includes";
      }
    else
      {
    $incpath = "/includes";
      }
    
    PHP:
     
    X.Homer.X, Jun 5, 2008 IP
  6. X.Homer.X

    X.Homer.X Peon

    Messages:
    290
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #26
    is there anyway i could do this?

    i searched google, but no results to suit what im after, maybe i searched the wrong thing. i dont know, hope sum1 can help me
     
    X.Homer.X, Jun 6, 2008 IP
  7. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #27
    
    $script_path = $_SERVER['SCRIPT_FILENAME'];
    if(preg_match('/admin/i', $script_path )) {
    $incpath = "../includes";
    }
    else { 
    $incpath = "/includes";
    }
    
    Code (markup):
    Should work.
     
    shallowink, Jun 6, 2008 IP
    X.Homer.X likes this.
  8. X.Homer.X

    X.Homer.X Peon

    Messages:
    290
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #28
    wow thanks, that worked like a charm =]

    +rep
     
    X.Homer.X, Jun 6, 2008 IP