Can I do this...

Discussion in 'PHP' started by Tiger33, Sep 22, 2007.

  1. #1
    Can I use one line of php that calls a block of Google ads from a php document on an html page?

    If so, what do I put in the .htaccess doc to do this?

    Any help would be appreciated!
     
    Tiger33, Sep 22, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Sorry but... can you be more specific?

    Do you want to parse a PHP page (not on your server?) and get the Google ads from this site and display them on one HTML page of yours?

    Whatever you're trying to do, it's probably against Google's TOS.
     
    nico_swd, Sep 22, 2007 IP
  3. litebulb1

    litebulb1 Peon

    Messages:
    151
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    sounds like you want php includes.
     
    litebulb1, Sep 22, 2007 IP
  4. Tiger33

    Tiger33 Guest

    Messages:
    38
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I want to call a php document that has my Google Adsense code into an html document. Everything is on my server. My extensions on my pages are htm

    Yes, I think I want php includes. Just not sure how to do it.

    I have a php example. I just don't know how to implement it into my htm page.
    Do I have to rename all of my pages to have php extension?
     
    Tiger33, Sep 22, 2007 IP
  5. buldozerceto

    buldozerceto Active Member

    Messages:
    1,137
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    88
    #5
    rename the htm to php
    and do this where u want to have the ads:
    include("googleads.php");
    of course replace the googleads with the page where the google ad code is
     
    buldozerceto, Sep 22, 2007 IP
  6. litebulb1

    litebulb1 Peon

    Messages:
    151
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #6
    litebulb1, Sep 22, 2007 IP
  7. khan11

    khan11 Active Member

    Messages:
    615
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    58
    #7
    if you cannot rename all your .htm to php then use iframe,, it might work ok. you can disable its scrolling,frameborder etc..
     
    khan11, Sep 22, 2007 IP
  8. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #8
    You can include html files in php, no need to rename them.
     
    matthewrobertbell, Sep 23, 2007 IP
  9. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #9
    In your .htaccess, add:
    AddType application/x-httpd-php .php .htm .html

    In your .html pages:
    <?php include 'google_ads.php'; ?>

    Where google_ads.php contains the adsense code.

    But that is not the best way to do it... but it seems you already have a site filled with static content.
     
    krt, Sep 23, 2007 IP
  10. Tiger33

    Tiger33 Guest

    Messages:
    38
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Thanks everyone for taking the time to reply to my questions.

    KRT,
    What is the best way to do this, then?
     
    Tiger33, Sep 28, 2007 IP
  11. chicagoweb

    chicagoweb Peon

    Messages:
    30
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Won't the iframe break the adsense functionality?
     
    chicagoweb, Sep 28, 2007 IP
  12. khan11

    khan11 Active Member

    Messages:
    615
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    58
    #12
    sorry, i was wrong to prefer iframes, because by putting adsense in an iframe, it cannot search content of site, as there is hell of difference between php include and iframe.

    so, you should rename all your files to .php and link them together and use include.

    here is what google replies regarding this issue.
    so, put your ads in file like google_ads.php and then include them on all of your pages in ads block using this tag: <? include("path/google_ads.php");?>
     
    khan11, Sep 28, 2007 IP