whast the best code to link a site

Discussion in 'PHP' started by kezhu911, Mar 23, 2009.

  1. #1
    I just wondering what's the best code to link a ad link to my website, because I need to update my ad very often, by doing this, I don't have to update every single pages
     
    kezhu911, Mar 23, 2009 IP
  2. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
    #2
    can you rebuild your question?
     
    crivion, Mar 23, 2009 IP
  3. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #3
    use include();

    use this on every page that you want the ads to show:

    include('ads.html');

    When you want to edit the links, just edit ads.html

    - ads2help
     
    ads2help, Mar 23, 2009 IP
  4. kezhu911

    kezhu911 Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    using the include code just not working for me, I dont know whats wrong
     
    kezhu911, Mar 23, 2009 IP
  5. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #5
    So, how have you implemented it?

    In the .php-file, for example index.php, you will place the include ('ads.html'); wherever you'd like the ads to show up.

    Note that the ads.html-file need to contain the exact presentational code to show the ads as you want. For instace, if the ad is in a javascript/iframe, just put the ad-code in the ads.html, do not put anything else there.

    The include()-function just takes whatever is in the file you link and puts it in the page where the include()-function is placed, so it's bascially the same as if you put the ad-code directly into the file, except that you won't have to update more than ads.html for changes to take effect.
     
    PoPSiCLe, Mar 23, 2009 IP
  6. kezhu911

    kezhu911 Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    <?php include ('http://www.mywebsite.com/myad.html');?>
    is this is the right code, my website is mixed with html, and some java


    this is how I start my code
    </head>
    <body bgcolor="#000000" text="#000000">
    <div id="bv_" style="position:absolute; left:6px; top:12px; width:243px; height:150px; z-index:0" align="left">

    <?php include ('http://www.mywebsite.com/myad.html');?>
    <font size="5">
    but it just won't display that ad
    or maybe cause my site is end with html? because I cant change all to .php now, I have too many pages
     
    kezhu911, Mar 23, 2009 IP
  7. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #7
    If the page is a .html file, it won't by default display php-code, no.

    You can, however, parse .html through php by editing your .htaccess-file.

    add this:
    AddType application/x-httpd-php .html
     
    PoPSiCLe, Mar 23, 2009 IP
  8. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #8
    Looks like you saved the file as UTF8 w/BOM . It will come back to haunt you.
     
    shallowink, Mar 23, 2009 IP
  9. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #9
    If the myad.html is located at same directory as your file, use this instead

    include ('myad.html');

    Don't use http://www.mywebsite.com/ inside.

    - ads2help
     
    ads2help, Mar 24, 2009 IP
  10. kezhu911

    kezhu911 Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    application/x-httpd-php .html
    for this code, where do I add it? at the begining of the page?
     
    kezhu911, Mar 29, 2009 IP
  11. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #11
    PoPSiCLe, Mar 29, 2009 IP
  12. wmtips

    wmtips Well-Known Member

    Messages:
    601
    Likes Received:
    70
    Best Answers:
    1
    Trophy Points:
    150
    #12
    1. Use relative path in your include, without http://
    2. Remove UTF BOM because it could break browser's rendering. (For example, if under Windows, re-save file with Notepad2 without "Signature")
     
    wmtips, Mar 29, 2009 IP