Welcome to Geeklog Thursday, June 27 2019 @ 02:01 am EDT

Geeklog Forums

Google php block


NOT so handyman

Anonymous
Hi i am realy new to php.. Today actually.. But i am trying to make a google ad sence block with php and am not sure whats wrong with it and if im doing it correctly. This is my code in the lib_common.php file and in the block i choose phpblock and put phpblock_googlead . any help would be appreciated thanks.

function phpblock_googlead()
{

echo '

google_ad_client = "pub-**************467";
google_ad_width = 120;
google_ad_height = 600;
google_ad_format = "120x600_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_page_url = document.location;
google_color_border = "191933";
google_color_bg = "333366";
google_color_link = "99CC33";
google_color_url = "FFCC00";
google_color_text = "FFFFFF";

';


$content .= '
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">

';

}

Status: offline

asmaloney

Forum User
Full Member
Registered: 08/02/04
Posts: 214

You probably want something more like this:
PHP Formatted Code

function phpblock_googlead()
{
  echo '
  <div align=center>
  <script type="text/javascript"><!--
    google_ad_client = "pub-***********";
...
    google_color_text = "6F6F6F";
  //--></script>
  <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
  </script>
  </div>'
;
}

 


Of course I haven't tried it - I'm a developer not a tester!

- Andy

Status: offline

beewee

Forum User
Full Member
Registered: 05/08/03
Posts: 969
Location:The Netherlands, where else?
Perhaps I've missed something, but what's wrong with putting the normal Adsense javascript code in an normal block or static page? It always worked fine for me.
Dutch Geeklog sites about camping/hiking: www.kampeerzaken.nl | www.campersite.nl | www.caravans.nl | www.caravans.net

Status: offline

asmaloney

Forum User
Full Member
Registered: 08/02/04
Posts: 214

Uh, well.. sputter, sputter, but it, ah... whatabout the uh...

You're right - I should have thought of that instead of blindly solving his problem.

- Andy

ddgeek.com

Anonymous
for some reason the javascript isnt working for me, the ads arent appearing, im not sure whats to blame at the moment though.

Status: offline

ronack

Forum User
Full Member
Registered: 27/05/03
Posts: 612
Have you set it in config as an allowable protocol?
PHP Formatted Code

// list of protocols that are allowed in links
$_CONF['allowed_protocols'] = array ('http:', 'https:', 'ftp:', 'javascript:');
 

Status: offline

loculus

Forum User
Newbie
Registered: 01/07/05
Posts: 14
This is just a guess as I'm learning too but if the error is indicating that the protocal is incorrect, then maybe you just have a typo or corrupt cut and paste of your Google code.

The only reason I say this is because when I cut and paste my own Google code into a basic html block some of the code was changed enough to give me some extra characters such as ->.

To solve it, I just tried again and it worked perfectly.

All times are EDT. The time is now 02:01 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content