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

6 replies · 1,301 views · started 16 years ago · 1 min read

5 participants
triplee084 Junior · 30 posts #1

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.

akangprabu Newbie · 3 posts #2

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

Jacide Newbie · 1 posts #5
<?php echo admob_request($admob_params); ?>
Guest #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.

darwin055 Junior · 14 posts #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

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close