Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Member inthezone's Avatar
    Join Date
    Sep 2002
    Posts
    59
    Member #
    192
    I'm trying to break up my site into directories, so that each .php file will be placed in an index.php file in a corresponding directory, e.g.

    contact.php => /contact/index.php
    about.php => /about/index.php
    etc
    I'm doing this so that I can implement a breadcrumb navigation system, but I'm running into some problems with my config.php file. The config file is located in my public_html directory, and I use it as a <?php require ?> on all of my pages that get content from my MySQL DB. When I try to require it in one of my directories, it can't connect to the database.

    For example, I have a directory called "contact", and its URL would be http://www.mysite.com/contact/

    Now for the index.php file in the contact directory, my require statements for the header and the footer work properly. Both the header and footer are located in the same directory (public_html) as the config.php file, and I call on the header and footers like this:

    PHP Code:
    <?php require('http://www.mysite.com/header.php'); ?>
    that works fine. But when I call on my config.php like that:

    PHP Code:
    <?php require('http://www.mysite.com/config.php'); ?>
    it doesn't load properly, and the connection cannot be made to the database. Why is this?
    The Extent of my PHP Knowledge:

    <?php
    print "In the Zone";
    ?>

  2.  

  3. #2
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Try reference the absolute path; for example: /home/inthezone/public_html/myscript/config.php.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  4. #3
    410
    410 is offline
    Senior Member 410's Avatar
    Join Date
    Nov 2002
    Posts
    109
    Member #
    284
    <?php require('http://www.mysite.com/dir/config.php'); ?>

    could you not just do it like that. i believe i have done this before

  5. #4
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Even if you can I vaguely remember reading that that counts against your bandwidth quota as the script has to go out and effectively download the file.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  6. #5
    Senior Member nsr81's Avatar
    Join Date
    Oct 2002
    Posts
    1,132
    Member #
    250
    Liked
    15 times
    Yup that's another DNS query, bandwidth and a bit slow(a few milliseconds), relative/absolute local paths are more efficient.

    Just consider something happens to your domain, DNS server error, and you access it through an alternative URL your site will be pretty much dead. ( CPanel allowes you to access the site through alternative URL, i.e. http://servername.com/~username )
    There and Back Again :Ogre:

  7. #6
    Member
    Join Date
    Jan 2003
    Location
    Moscow City
    Posts
    32
    Member #
    468
    Had the same problem?

    You meant somethig like this?

    PHP Code:
    <?php
    //nav_dir.php
    $default_dir "/home/james";
    function 
    traverse_dir($dir) {
       echo 
    "Traversing $dir....<BR>";
       
    chdir($dir);
       if(!(
    $dp opendir($dir))) die("Can't open $dir.");

       while(
    $file readdir($dp)) {
          if(
    is_dir($file)) {
             if(
    $file != '.' && $file != '..') {
                echo 
    "/$file<BR>";
                
    traverse_dir("$dir/$file");
                
    chdir($dir);
             }
          }
          else echo 
    "$file<BR>";
          
       }
       
       
    closedir($dp);
    }

    traverse_dir($default_dir);

    ?>
    Want a dynamic site with nice graphics? Solutions for the new age. Marco Tech
    vBulletin skins | Button sets | Free Photoshop addons | Web templates | PHP


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:43 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com