Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Posts
    100
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Easy about php includes. So I thought!

    This is what I'm attempting to do.

    On my first /index.php. I want to include my toplist. Which is in a sub directory called /toplist/index.php

    I have added the code

    Code:
    <?php include "/toplist/index.php"; ?>
    But I'm recieving errors for another file that that index.php needs.

    Here is my front page - http://www.font-factory.com

    Here is the toplist I wish to include - http://www.font-factory.com/toplist/index.php

    In the toplist directory contains other directories needed to run the toplist.

    Do I need to use require, or rewrite the whole (spanish) script!!??

    Basically I wish to keep all the toplist scripts relative to the Index.php even though it will be called from a directory above it (If that makes sense?).

    I need to get this sorted ASAP as my members are waiting to rejoin my new toplist!

    Please help me.......

    Fanx in Advance.

    Golden Eagle
    Admin of Font-Factory.com
    Last edited by Golden_Eagle; 04-17-2003 at 01:55 PM.

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Depends on the time of year
    Posts
    478
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try this:

    PHP Code:

    include $_SERVER['DOCUMENT_ROOT']."/toplist/index.php"
    This is what they are saying for the open_basedir error on php.net

    open_basedir string
    "Limit the files that can be opened by PHP to the specified directory-tree. This directive is NOT affected by whether Safe Mode is turned On or Off.

    When a script tries to open a file with, for example, fopen or gzopen, the location of the file is checked. When the file is outside the specified directory-tree, PHP will refuse to open it. All symbolic links are resolved, so it's not possible to avoid this restriction with a symlink.

    The special value . indicates that the directory in which the script is stored will be used as base-directory.

    Under Windows, separate the directories with a semicolon. On all other systems, separate the directories with a colon. As an Apache module, open_basedir paths from parent directories are now automatically inherited.

    The restriction specified with open_basedir is actually a prefix, not a directory name. This means that "open_basedir = /dir/incl" also allows access to "/dir/include" and "/dir/incls" if they exist. When you want to restrict access to only the specified directory, end with a slash. For example: "open_basedir = /dir/incl/"

    Opomba: Support for multiple directories was added in 3.0.7.

    The default is to allow all files to be opened. "

    Duniyadnd
    Last edited by duniyadnd; 04-10-2003 at 06:04 PM.

  • #3
    New Coder
    Join Date
    Feb 2003
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try this :

    <?php include("./toplist/index.php"); ?>

    It will probably work. At least this is what i use with no problems at all.

  • #4
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Why not just:

    <?php include("toplist/index.php"); ?>

  • #5
    Regular Coder
    Join Date
    Jul 2002
    Posts
    100
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have tried all 3 of these suggestions and it does'nt want to work.

    Has anyone got any other ideas?

    I can't understand why these are working for others and not me!

    At the moment I have this in my page -

    Code:
    <td colspan="3">
    <table width="100%" border="0" cellpadding="15">
    <tr><td width="300">
    <font size="2"><b>Top Five FontSites</b><br>
    <center>
    <?php include $_SERVER ['DOCUMENT_ROOT']."/toplist/index.php"; ?>
    </center></font></td>
    HELP PLEASE!
    Last edited by Golden_Eagle; 04-10-2003 at 06:32 PM.

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    Depends on the time of year
    Posts
    478
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PHP Code:
    include $_SERVER 'DOCUMENT_ROOT']."/toplist/index.php"

    //You're missing the "["

    include $_SERVER['DOCUMENT_ROOT']."/toplist/index.php"
    Duniyadnd

  • #7
    Regular Coder
    Join Date
    Jul 2002
    Posts
    100
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry. That was a typo on my behalf!

    That script IS actually correct on my page though, (still doesn't work!)

  • #8
    Regular Coder
    Join Date
    Jun 2002
    Location
    Depends on the time of year
    Posts
    478
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Make sure there's no space between $_SERVER and the "["

    Try this. Instead of "include" put echo and see what prints out. If you think its in the right directory, then try

    echo file_exists($_SERVER['DOCUMENT_ROOT']."/toplist/index.php");

    and see if it returns true (it should print out 1). If it doesn't, then the file doesn't exist there and there seems to be a problem where you think its located.

    Duniyadnd

  • #9
    Regular Coder
    Join Date
    Jun 2002
    Location
    Depends on the time of year
    Posts
    478
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If that doesn't work, what version of php are you using?

  • #10
    Regular Coder
    Join Date
    Jul 2002
    Posts
    100
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I placed that code and have got a 1 (http://www.font-factory.com)

    http://www.font-factory.com/phpinfo.php

    I thought this would be nice n easy! LOL

    Shows what I know!
    Last edited by Golden_Eagle; 04-10-2003 at 07:14 PM.

  • #11
    Regular Coder
    Join Date
    Jun 2002
    Location
    Depends on the time of year
    Posts
    478
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Okay, so we know the file does exist.. I recommend you check your code for the toplist/index.php and see that nothing stands out that might intervene with the main page.

    Like remove extra <html> tags etc. of if you have a cookie on that page, make sure its right at the beginning etc.

    In fact, try it with another file, which just has some simple text in it, and carry on from there.

    Duniyadnd
    Last edited by duniyadnd; 04-10-2003 at 08:01 PM.

  • #12
    Regular Coder
    Join Date
    Jul 2002
    Posts
    100
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I know that the toplist/index.php page is being added to the main page. But it's the pages connected to the toplist/index.php I'm having problems with.

    The file index.dat for example cannot be found by the toplist/index.php because it effectively has been loaded in the root of my site.

    I'll try to explain a little bit more in detail

    Front page
    http://www.font-factory.com/index.php

    Toplist Page
    http://www.font-factory.com/toplist/index.php

    In Front Page is an include for the Toplist Page.
    In the Toplist Page other files are needed.

    ie
    http://www.font-factory.com/toplist/data/index.dat

    Becaues the file toplist/index.php had been loaded onto my Main Page (http://www.font-factory.com).

    The index.dat file is no longer located at data/index.dat (which is what is stated in about a million different places) it is now in toplist/data/index.dat

    There are loads of other files related to this toplist and to change them all would be a complete nightmare. Especially as I'm a PHP nOOb!
    Last edited by Golden_Eagle; 04-10-2003 at 08:18 PM.

  • #13
    Regular Coder
    Join Date
    Jun 2002
    Location
    Depends on the time of year
    Posts
    478
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Gotcha, then its an easy fix.

    Do the same thing you did to call the first file for all the includes:

    include $_SERVER['DOCUMENT_ROOT']."/location/file.php";

    Takes care of everything.

    Duniyadnd

  • #14
    Regular Coder
    Join Date
    Jul 2002
    Posts
    100
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That is what I'm trying to avoid doing.

    The whole script has loads of different different files, that are included into each other to change the lot would be extremely hazardous.

    Is there any other way of doing it?

  • #15
    Regular Coder
    Join Date
    Jul 2002
    Posts
    100
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What about the include_path() function. Is that what I need? Can anyone confirm that his may work please?

    Include_path()

    This is getting somewhat frustrating now. Please assist!


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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