Why would an include not be working?

Discussion in 'PHP' started by GloBleeOne, May 18, 2008.

  1. #1
    Hi there, I have been playing round for ages, and can not get the following to work:

    
    <?php
    $path="/home/example/public_html/photogifts/uploader/";
    if (getdomain($path) == 'www.example.co.nz'){
         include($path.'form.php');
    }
    ?>
    
    Code (markup):
    or

    <?php include("/home/example/public_html/photogifts/uploader/form.php");?>
    Code (markup):
    trying to include in an uploader form from the uploader directory in the index file of the photogifts directory.
     
    GloBleeOne, May 18, 2008 IP
  2. zerxer

    zerxer Peon

    Messages:
    368
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The second one should work fine so long as that's an actual path to the file. The first one I can't really say since I don't know what the getdomain() function does or how it figures out if that path links to that domain (since it's not like the domain is mentioned in it).
     
    zerxer, May 18, 2008 IP
  3. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #3
    The bogey monster won't allow you.

    On the other hand, the second code should work fine. Try debugging (echo 1 on form.php).

    If all fails, use require instead and it'll throw an error and tell us that error to help you out.

    Peace,
     
    Barti1987, May 18, 2008 IP
  4. Perow

    Perow Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    My idea is that your path is relative to your root, which is not public. Try the following:
    
    <?php
    $path="../photogifts/uploader/";
    if (getdomain($path) == 'www.example.co.nz'){
         include($path.'form.php');
    }
    ?>
    PHP:
     
    Perow, May 19, 2008 IP
  5. xrvel

    xrvel Notable Member

    Messages:
    918
    Likes Received:
    30
    Best Answers:
    2
    Trophy Points:
    225
    #5
    Try to get the current path to get the next step :)
    
    
    echo(dirname(__FILE__));
    
    
    PHP:
     
    xrvel, May 19, 2008 IP