Problem with moving from xammp localhost to a webserver

Discussion in 'PHP' started by j_o, Jul 18, 2011.

  1. #1
    Hi everyone,

    I have a website that I have been creating using xammp and I have a folder called include that I call on every page which loads my functions and connection variables.

    I used this code:

    <?php
        require_once('includes\connection.php');
        require_once('includes\functions.php');
        $public = TRUE;
    ?>
    PHP:
    It was all working perfectly on my localhost which is a just a copy of xampp running on my computer. I then uploaded it to the webserver (provided by netfirms.com) and I am getting errors that the require_once function is failing to open the stream.

    As you can see it is saying that the file or directly dont exist however I have checked the server and the files show with no problems.

    Any ideas what my problem is? Thanks in advance.
     
    j_o, Jul 18, 2011 IP
  2. SiJz

    SiJz Peon

    Messages:
    51
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi

    try / instead of \ in the url - \ usually comes before special characters

    Failing that:
    - I know it's a dumb suggestion - but first ensure you have actually uploaded them to the right location...
    - Then check upper/lower case errors - easily done and causes much problems when moving from windows to apache box
    - After that, try calling the php from the browser - so yourdomain/includes/functions.php etc - check you can access it

    Hope that helps,

    Si
     
    SiJz, Jul 18, 2011 IP
    j_o likes this.
  3. j_o

    j_o Well-Known Member

    Messages:
    516
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    113
    #3
    Thanks Si, after trying what you said and looking at php.net I found a little piece of code that finds the directory for me and puts the path in.

    If your interested heres the code:

    define('__ROOT__', dirname(dirname(__FILE__)));
    //require_once(__ROOT__.'/config.php);
    PHP:
     
    j_o, Jul 18, 2011 IP
  4. SiJz

    SiJz Peon

    Messages:
    51
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Glad you're sorted,

    Si
     
    SiJz, Jul 18, 2011 IP