Forum Moderators: martinibuster

Message Too Old, No Replies

Can some one show me how to add google adsense to my site using php.

         

ballhogjoni

6:37 am on Mar 31, 2006 (gmt 0)

10+ Year Member



Can some one show me how to add google adsense to my site using php. i mean i went to this site <snip>, and they are somehow syndicating yahoo ads. how would i do the same thing for google ads?

[edited by: trillianjedi at 3:59 pm (utc) on Mar. 31, 2006]
[edit reason] No URL's please as per TOS. [/edit]

eeek

7:20 am on Mar 31, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



/* php stuff */?>

AdSense Code

<? */ back to php */

MyGen

9:40 am on Mar 31, 2006 (gmt 0)

10+ Year Member



--------------
ads.inc
--------------

Adsense code here


--------------
All your other pages you want ads on
--------------

<? include_once("ads.inc");?>

ballhogjoni

3:37 pm on Mar 31, 2006 (gmt 0)

10+ Year Member



Thx for your replies, but i am a newbie with php and mysql. mygen it looks like your talking mysql? If you could please do me a favor and explain it in lamens terms. i know html really well and i hear php isnt hard to learn. what i mean is that it looks like he actually uses a script or something to pull in specific keywords and then the script grabs the right ads from yahoo. please look at this guys/girls site and view the source if you dont know what i mean.

Andrew Bassett

3:50 pm on Mar 31, 2006 (gmt 0)

10+ Year Member



Ballhogjoni, it's as simple as this...

Your PHP code is enclosed within <?php?> tags, and your HTML goes outside the tags, like this:

<?php
if (1 + 1 == 2)
{
// Whatever
}
?>

<!-- AdSense code (HTML) goes here! -->

<?php
// More PHP code
?>

imstillatwork

7:20 pm on Mar 31, 2006 (gmt 0)

10+ Year Member



learn.

londrum

7:59 pm on Mar 31, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



save the google code (exactly as they supply it) onto a completely blank page.
save it as googlecode.php (or whatever you want)

and then put
<? include("googlecode.php");?>
on your main pages, wherever you want it to appear - remembering to change googlecode.php so it points to wherever it is you saved it.

you main page can either be .html .htm .php - depending on how your server is set-up.
but you won't be able to view it on your home computer unless you have apache or some other kind of server installed.
you can download apache for free on the web. just do a search.

it sounds hard but it's pretty easy. you could have it up and running within a couple of hours.