Web Analytics Made Easy -
StatCounter include problem in php - CodingForum

Announcement

Collapse
No announcement yet.

include problem in php

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • include problem in php

    i am running a file in the following folder on my hosting server

    /httpdocs/folder1/folder2/script.pjp

    how do i include a file that is located at the root of the hosting server

    /httpdocs/globalFunctions.php


    iv tried
    PHP Code:
    $maindir dirname(__FILE__) . DIRECTORY_SEPARATOR;
    require 
    $maindir DIRECTORY_SEPARATOR "globalFunctions.php"
    PHP Code:
    include('http://www.domainname.com/globalFunctions.php'); 
    and
    PHP Code:
    include('../../globalFunctions.php'); 
    but none of these work

    any ideas

  • #2
    Think you might need some changes on open_basedir and/or safe mode to allow this.

    Comment


    • #3
      Originally posted by m1l View Post
      Think you might need some changes on open_basedir and/or safe mode to allow this.
      can you explain abit more about this. i cant find anything on google about it

      Comment


      • #4
        Originally posted by kevinkhan View Post
        PHP Code:
        include('http://www.domainname.com/globalFunctions.php'); 
        That will never work as the server sees it as a http request and EXECUTES the PHP file. All you will see is html output NOT php code.
        "Tango says double quotes with a single ( ' ) quote in the middle"
        '$Name says single quotes with a double ( " ) quote in the middle'
        "Tango says double quotes ( \" ) must escape a double quote"
        '$Name single quotes ( \' ) must escape a single quote'

        Comment


        • #5
          Originally posted by tangoforce View Post
          That will never work as the server sees it as a http request and EXECUTES the PHP file. All you will see is html output NOT php code.
          sorry guys i got it.. was a simple mistake

          This is what I used in the end and it worked grand

          PHP Code:
          $globalFunctions $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR 'globalFunctions.php';

          include(
          $globalFunctions); 

          Comment

          Working...
          X