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.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jun 2009
    Posts
    351
    Thanks
    75
    Thanked 0 Times in 0 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
    m1l
    m1l is offline
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    8
    Thanks
    0
    Thanked 1 Time in 1 Post
    Think you might need some changes on open_basedir and/or safe mode to allow this.

  • #3
    Regular Coder
    Join Date
    Jun 2009
    Posts
    351
    Thanks
    75
    Thanked 0 Times in 0 Posts
    Quote 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

  • #4
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,327
    Thanks
    60
    Thanked 525 Times in 512 Posts
    Blog Entries
    4
    Quote 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.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #5
    Regular Coder
    Join Date
    Jun 2009
    Posts
    351
    Thanks
    75
    Thanked 0 Times in 0 Posts
    Quote 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); 


  •  

    Posting Permissions

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