new to php...cant embed in html...help please

Discussion in 'PHP' started by newdawn, Jun 12, 2008.

  1. #1
    I've got a bunch of html files and want adsense in all those.

    So i read up some material online and did the following things

    - made an adsense.php that just has the adsense code in it
    - put the following line in the html at the point where i want the ads
    <?php include("adsense.php") ?>

    But the ads just don't show up. The html and php files are in the same folder and my host does have php installed coz i can run wordpress on it.

    Help please!
     
    newdawn, Jun 12, 2008 IP
  2. mehmetm

    mehmetm Well-Known Member

    Messages:
    134
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #2
    you normally can't run php codes in html such
    <?php include("adsense.php") ?>
    PHP:
    for doing this, the shortest way I know is creating a .htaccess file, paste this code in it and upload it your ftp's public dir.

    here is the code:
    
    RemoveHandler .html .htm
    AddType application/x-httpd-php .php .htm .html
    
    Code (markup):
    Regards.
     
    mehmetm, Jun 12, 2008 IP
  3. newdawn

    newdawn Peon

    Messages:
    436
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    awesome! worked beautifully...
    thanks mehmetm

    mind explaining what exactly this does?

     
    newdawn, Jun 12, 2008 IP
  4. blueparukia

    blueparukia Well-Known Member

    Messages:
    1,564
    Likes Received:
    71
    Best Answers:
    7
    Trophy Points:
    160
    #4
    You can not run that in .htm or .html (only .php) files natively, so that code makes .html files on your server/directory identify as .php files.
     
    blueparukia, Jun 12, 2008 IP
  5. newdawn

    newdawn Peon

    Messages:
    436
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    oh oh! alright....thanks a lot...

    you are all great
     
    newdawn, Jun 12, 2008 IP
  6. Dondon2d

    Dondon2d Peon

    Messages:
    3,193
    Likes Received:
    146
    Best Answers:
    0
    Trophy Points:
    0
    #6
    To sum things up, you can only run a PHP script such as the one you used to include adsense.php on a file with .php as extension. :)
     
    Dondon2d, Jun 12, 2008 IP
  7. mehmetm

    mehmetm Well-Known Member

    Messages:
    134
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #7
    using this code your all .htm and .html files are being parsed as PHP scripts.

    that means, if your .htm or .html files include some PHP codes in there, these codes will be worked properly as PHP codes.

    However, using this method has a bit performance loss. I mean parsing PHP files which include just PHP codes is faster than parsing HTML files which include PHP codes between HTML codes..

    Regards.
     
    mehmetm, Jun 12, 2008 IP