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.
How to display two admob advert code on 1 page
Started on the old forum in October 2010 · view the original in the archive · old links redirect here
try this. create some files like admob.php
<?
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
Always NEWBIE
??
just put
echo admob_request($admob_params);
on footer or wer else u want to display admob ads
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.