How to display two admob advert code on 1 page

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to display two admob advert code on 1 page

    I have been trying to display admob advert on the header and footer of my site. I use
    include("admob.php"); on the header
    and include("admob.php"); on the footer. And the whole page goes blank. Pls help.

    #2
    try this. create some files like admob.php
    PHP Code:
    <?
    function mobads()

    {

    $mob_mode = "test";

    $mob_alternate_link = "Type your other link"; //this link show when ads form admob is not show



    $mob_ua = urlencode(getenv("HTTP_USER_AGENT"));

    $mob_ip = urlencode($_SERVER['REMOTE_ADDR']);



    if ($mob_mode=='live')

    $mob_m = "&m";

    $mob_url = 'http://ads.admob.com/ad_source.php?s=your admob kode here&u='.$mob_ua.'&i='.$mob_ip.$mob_m;

    @$mob_ad_serve = fopen($mob_url,'r');

    if ($mob_ad_serve)

    {

    while (!feof($mob_ad_serve))

    $mob_contents .= fread($mob_ad_serve,1024);

    fclose($mob_ad_serve);

    }

    $mob_link = explode("><",$mob_contents);

    $mob_ad_text = $mob_link[0];

    $mob_ad_link = $mob_link[1];

    if (isset($mob_ad_link) && ($mob_ad_link !=''))

    $ret = "<a href=\"$mob_ad_link\">$mob_ad_text</a><br/>";

    else

    $ret = $mob_alternate_link;



    return $ret;



    }

    ?>

    and then in page where you wanna show ads, you just type

    echo mobads();


    sorry if Im false

    Added after 56 minutes:

    sorry forget.

    include "admob.php";

    at top your page
    Last edited by akangprabu; 17.10.10, 04:42.

    Comment


      #3
      ??

      just put

      echo admob_request($admob_params);

      on footer or wer else u want to display admob ads

      Comment


        #4
        Did not work

        Comment


          #5
          <?php
          echo admob_request($admob_params);
          ?>

          Comment


            #6
            its very simple and so easy, first add your admob php code in one file like make admob.php and add admob code in that file. than just remove line from admob.php: echo admob_request($admob_params);

            then add admob.php in head of any php file, like in head of any php script add line: include "admob.php";
            then just add this line in your body of script: echo admob_request($admob_params);
            you can add this functions many times in one php script, you just need to add admob.php in header only.
            hope you understand.

            Comment


              #7
              try to create admob2.php then change code function admob to function admob2 then u can put in index include admob.php for header and admob2,php for footer

              Comment

              Working...
              X