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.

Need a php include snippet

Discussion in 'PHP' started by Gnet, Jul 18, 2008.

  1. #1
    I need a php include snippet made so that i can include the following network bar into other files via php.

    http://www.askteens.net/top/headness.html


    I need a working code, if anyone can help it's much appreciated
     
    Gnet, Jul 18, 2008 IP
  2. scriptglue

    scriptglue Banned

    Messages:
    170
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Is this what your looking for?

    <?php include("http://www.askteens.net/top/headness.html"); ?>
    PHP:
     
    scriptglue, Jul 18, 2008 IP
  3. Gnet

    Gnet Peon

    Messages:
    5,340
    Likes Received:
    529
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Gnet, Jul 18, 2008 IP
  4. Fl1p

    Fl1p Active Member

    Messages:
    511
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    58
    #4
    You just need to add the code below where you want it to show.
    <?php include("http://www.askteens.net/top/headness.html"); ?>

    Just a note that while I was looking at your URL source, it has html, head and body tags so just make sure to get rid of that if you're adding the code above where there's already html, head and body tags otherwise you'll have duplicate set of tags.

    Click the link below for more info about the include function
    http://ca.php.net/include/
     
    Fl1p, Jul 18, 2008 IP
  5. Fl1p

    Fl1p Active Member

    Messages:
    511
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    58
    #5
    Try getting rid of the URL so its just...
    <?php include("top/headness.html"); ?>
     
    Fl1p, Jul 18, 2008 IP
    Gnet likes this.
  6. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #6
    And that will work as long as the file with the include statement is at the top level of the website. If you have pages in folders they would have to use ../ to go back up to the top level. Like so:


    <?php include("../top/headness.html"); ?>
    PHP:
     
    shallowink, Jul 18, 2008 IP
  7. Gnet

    Gnet Peon

    Messages:
    5,340
    Likes Received:
    529
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I dont think that code would work on subdomains such as

    mp3.askteens.net
     
    Gnet, Jul 18, 2008 IP
  8. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #8
    It could work. Really depends on how the structure of the website is setup. Given most sub domains are actually pointers to a folder off the main domain(which is the top level), its exactly what would be needed. If you have mp3.askteens.net and the directory structure was like so
    /
    /mp3.askteens.net
    /mp3.askteens.net/callingfile.php
    /top
    /top/filetoinclude.php

    With / being www.askteens.net, if you wanted to include a file from /top on mp3.askteens.net it would be

    include "../top/filetoinclude.php"

    But as always with includes, it depends on how your host has it set up. Some hosts it would require additional work, like on mediatemple.net. They have a screwy file setup for domains and subdomains. It would require so much effort to traverse directories it wouldn't make sense to include a domain file on a subdomain since they treat subdomains pretty much as independent sites. Now if the sub domain was hosted elsewhere it wouldn't work at all.
     
    shallowink, Jul 18, 2008 IP
    Gnet likes this.
  9. scriptglue

    scriptglue Banned

    Messages:
    170
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Here is another way to include a page remotely
    
    <?php
    
    $menu = file_get_contents("http://www.askteens.net/top/headness.html");
    echo $menu;
    
    ?>
    
    PHP:
     
    scriptglue, Jul 18, 2008 IP
    Gnet likes this.
  10. Gnet

    Gnet Peon

    Messages:
    5,340
    Likes Received:
    529
    Best Answers:
    0
    Trophy Points:
    0
    #10
    thanks it worked
     
    Gnet, Jul 18, 2008 IP
  11. scriptglue

    scriptglue Banned

    Messages:
    170
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Your welcome.. let me know if you need help with anything else. :)
     
    scriptglue, Aug 11, 2008 IP