SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2008
    Location
    England
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    include relative addresses

    I am building a system that includes all validation, database function php pages in one global page

    then in my system I will call the global page which will hold all the includes.
    This is done to save time adding all the includes on every page.

    Problem is that when i call the global.php script when in another folder the pages in the global can't be found.

    setup
    global.php

    include '../scripts/dbconfig.php';
    include '../scripts/validation.php;

    main pages

    include 'global.php';

    when in root it is fine, when calling global.php in e.g. website folder/pages/ the scripts in the global.php cant be found.

    i assume it is a relative linking problem, anyway i can resolve this issue?

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Define a base path, then call all files relative to this constant, this should resolve the issues you're experiencing.

    PHP Code:
    <?php
    define
    ('BASE_PATH''/homes/user/www/');
    require 
    BASE_PATH 'validation.php';
    ?>
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.


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
  •