Problem with include

Discussion in 'PHP' started by PinoyIto, Nov 26, 2008.

  1. #1
    Hello to all,

    Will you please tell me or help me about my problem regarding php include.

    When I am using include no result is displaying...

    For example view.php is stored at my siteA.com and I want o include that file in my siteB.com

    So what I am doing to call the file is include "http://siteA.com/view.php"; but no result is showing. The screen is blank. I am expecting something like displaying some message or what inside the view.php

    I tried at siteA.com the following code include "view.php"; and it works well but if I tried this include "http://siteA.com/view.php"; not working...

    any idea why it's not working and any solution for this?
     
    PinoyIto, Nov 26, 2008 IP
  2. djzmo

    djzmo Active Member

    Messages:
    165
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #2
    try this..
    
    <?php
    print @file_get_contents('http://siteA.com/view.php');
    ?>
    
    PHP:
     
    djzmo, Nov 27, 2008 IP
  3. harrisunderwork

    harrisunderwork Well-Known Member

    Messages:
    1,005
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    135
    #3
    Remote file inclusion is disabled by default as it is big security risk.
     
    harrisunderwork, Nov 27, 2008 IP
  4. peeeev

    peeeev Peon

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    enable "allow_url_fopen" in php.ini:

    should be:
    allow_url_fopen = On

    But as said above it is a big security risk.
     
    peeeev, Nov 28, 2008 IP
  5. harrisunderwork

    harrisunderwork Well-Known Member

    Messages:
    1,005
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    135
    #5
    RFI vulnerability can be exploited .
     
    harrisunderwork, Nov 28, 2008 IP
  6. misbah

    misbah Active Member

    Messages:
    265
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    68
    #6
    you can't do this...
    cause include function only work on relative part or full part of your file....
    and not work on remote file...
    and if you try to get php file using file_get_content, the result not your file script but your output script (like html source code) cause server (siteA.com) will compile php file.
    but if your file is txt (not php) you can do this (file_get_content) cause the server on siteA.com not compile txt file
     
    misbah, Nov 28, 2008 IP
  7. mrmaf

    mrmaf Peon

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Yeah, include, include_once, require, require_once functions work for files that place at relative path.
     
    mrmaf, Nov 29, 2008 IP