1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

include

Discussion in 'PHP' started by dean5000v, Jun 9, 2008.

  1. #1
    hey well i want to include this subdomain information onto my website using the include function in php, so here is the link to the sub domain.

    http://shop.safetynetdirect.com/cgi-bin/mk_cat.pl?cat=B_NG1

    Now i've tried using using_once('http://shop.safetynetdirect.com/cgi-bin/mk_cat.pl?cat=B_NG1')
    but it gives me errors, so i checked my php info and saw that

    allow_url_include is set to off, is this the problem ???
     
    dean5000v, Jun 9, 2008 IP
  2. goscript

    goscript Prominent Member

    Messages:
    2,753
    Likes Received:
    306
    Best Answers:
    0
    Trophy Points:
    315
    #2
    You can only include another php file, not a full page of html..
    Also, when including make sure you use the relative path.
     
    goscript, Jun 9, 2008 IP
  3. dean5000v

    dean5000v Peon

    Messages:
    201
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    but i cnt use the relative path can i because its on a sub domain. And i'm tryin to avoid iframes at all costs so do you know another way i cld grab this information variable from the url.
     
    dean5000v, Jun 9, 2008 IP
  4. mehmetm

    mehmetm Well-Known Member

    Messages:
    134
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #4
    mehmetm, Jun 9, 2008 IP
  5. dean5000v

    dean5000v Peon

    Messages:
    201
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    i tried this

    <?php
    $handle = fopen("http://safetynetdirect.com/tcs/index.php", "r");
    echo " $handle ";
    ?>


    but all i get is this text resource id#5 any ideas,
     
    dean5000v, Jun 9, 2008 IP
  6. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #6
    The handle is just a pointer to the file resource. You have to use fread to get to the content.
    http://tr2.php.net/manual/en/function.fread.php
    
     $handle = fopen("http://safetynetdirect.com/tcs/index.php", "r");
    $contents = '';
    while (!feof($handle)) {
      $contents .= fread($handle, 8192);
    }
    fclose($handle);
    
    echo $content;
    
    Code (markup):
     
    shallowink, Jun 9, 2008 IP
  7. dean5000v

    dean5000v Peon

    Messages:
    201
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    even that doesn't work :(
     
    dean5000v, Jun 9, 2008 IP
  8. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #8
    Odds are its restrictions from your webhost.
     
    shallowink, Jun 9, 2008 IP
  9. Lordo

    Lordo Well-Known Member

    Messages:
    2,082
    Likes Received:
    58
    Best Answers:
    0
    Trophy Points:
    190
    #9
    You will need this:
    <?
    $c = file_get_contents("http://shop.safetynetdirect.com/cgi-bin/mk_cat.pl?cat=B_NG1");
    echo $c;
    ?>
    PHP:
     
    Lordo, Jun 9, 2008 IP
  10. lui2603

    lui2603 Peon

    Messages:
    729
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #10
    try:
    
    $file = file_get_contents('http://shop.safetynetdirect.com/cgi-bin/mk_cat.pl?cat=B_NG1');
    echo $file;
    
    PHP:
    If you only want to display part of the page you could use regexp to match unique parts of the html ;)


    EDIT: few seconds too late.. haha
     
    lui2603, Jun 9, 2008 IP
  11. Lordo

    Lordo Well-Known Member

    Messages:
    2,082
    Likes Received:
    58
    Best Answers:
    0
    Trophy Points:
    190
    #11
    Same moment :)
    4:39
     
    Lordo, Jun 9, 2008 IP
  12. dean5000v

    dean5000v Peon

    Messages:
    201
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    is there no way other way i can get around gettin this information then, rather then using a iframe ?
     
    dean5000v, Jun 9, 2008 IP
  13. dean5000v

    dean5000v Peon

    Messages:
    201
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    dean5000v, Jun 9, 2008 IP
  14. Lordo

    Lordo Well-Known Member

    Messages:
    2,082
    Likes Received:
    58
    Best Answers:
    0
    Trophy Points:
    190
    #14
    Please explain more. Why don't you want to use file_get_contents?
     
    Lordo, Jun 9, 2008 IP
  15. Lordo

    Lordo Well-Known Member

    Messages:
    2,082
    Likes Received:
    58
    Best Answers:
    0
    Trophy Points:
    190
    #15
    OK now you can make some work to $c before you echo it. For example, use a regular expression that checks for images without full URL and adds the URL to them.
     
    Lordo, Jun 9, 2008 IP
  16. dean5000v

    dean5000v Peon

    Messages:
    201
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16
    i want to use get file contents but look at the link i have given, now the image links are broken and bottons. o and thanks alot everyone for tryin to help :D
     
    dean5000v, Jun 9, 2008 IP
  17. dean5000v

    dean5000v Peon

    Messages:
    201
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    ok thanks alot i get what u mean now, if anyone has any snippits for code for this i wld appreciate it :D

    il look into it now !!!
     
    dean5000v, Jun 9, 2008 IP
  18. Lordo

    Lordo Well-Known Member

    Messages:
    2,082
    Likes Received:
    58
    Best Answers:
    0
    Trophy Points:
    190
    #18
    If you need an advice, then I would say google for it before you get help because regular expressions need searching and reading before you use them. And they will open a new horizon for you :)
     
    Lordo, Jun 9, 2008 IP
  19. dean5000v

    dean5000v Peon

    Messages:
    201
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #19
    yeah ive read like 3 php books so i know about regular expressions just haven't really used them to much apart from checking a email is valid ect. thanks for advice :D
     
    dean5000v, Jun 9, 2008 IP
  20. Lordo

    Lordo Well-Known Member

    Messages:
    2,082
    Likes Received:
    58
    Best Answers:
    0
    Trophy Points:
    190
    #20
    LOOOOL OK
    I checked the page and found that they use this format for images:
    <img src="/
    So, you can create your expression on this.
    But BTW: I checked their page now and it is changed! It shows a hand in gloves, what happened?
     
    Lordo, Jun 9, 2008 IP