Welcome to Geeklog, Anonymous Thursday, July 17 2025 @ 01:55 pm EDT

Geeklog Forums

Google php block


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">

';

}
 Quote

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

You probably want something more like this:
Text 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! Shocked

- Andy
 Quote

Status: offline
Forum User
Full Member
Registered: 08/05/03
Posts: 969
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.
 Quote

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

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

You're right - I should have thought of that instead of blindly solving his problem. Doh! - that was a mistake

- Andy
 Quote

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

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

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

Status: offline
Forum User
Newbie
Registered: 07/01/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.
 Quote

All times are EDT. The time is now 01:55 pm.

  • 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