Forum Moderators: coopster
Then I just put $googlebottom in the place I wanted the bottom advert and it works.
Don't forget to backslash every " you find in the code like \"
$googlebottom=("
<script type=\"text/javascript\"><!--
google_ad_client = \"**********";
google_ad_width = 336;
google_ad_height = 280;
google_ad_format = \"336x280_as\";
google_ad_type = \"text_image\";
google_ad_channel = \"*****************\";
google_color_border = \"FAFAF6\";
google_color_bg = \"FAFAF6\";
google_color_link = \"008486\";
google_color_url = \"008000\";
google_color_text = \"000000\";
//--></script>
<script type=\"text/javascript\"
src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">
</script>
");
$googlescript = <<< eof
<script type="text/javascript"><!--
google_ad_client = "**********";
google_ad_width = 336;
google_ad_height = 280;
google_ad_format = \"336x280_as\";
google_ad_type = "text_image";
google_ad_channel = "*****************";
google_color_border = "FAFAF6";
google_color_bg = "FAFAF6";
google_color_link = "008486";
google_color_url = "008000";
google_color_text = "000000";
//--></script>
<script type=\"text/javascript\"
src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">
</script>
eof;
If you want to put the script in some other PHP variable you can do this:
$content = "blah blah blah {$googlescript} blah blah";
Or if you want to put the script in the HTML you can use:
<?php print $googlescript;?>
Or you can save the Google script in a text file as an include called (say) google.inc. Then call it from within your HTML by:
<?php require ("domain.com/directory/google.inc");
Another option would be to do would be this:
<?php
print $header;
print $content;
// print whatever
if ($showAdsense)
{
// ohnoes, here comes the google code
?>
<script type="text/javascript"><!--
google_ad_client = "**********";
google_ad_width = 336;
google_ad_height = 280;
google_ad_format = \"336x280_as\";
google_ad_type = "text_image";
google_ad_channel = "*****************";
google_color_border = "FAFAF6";
google_color_bg = "FAFAF6";
google_color_link = "008486";
google_color_url = "008000";
google_color_text = "000000";
//--></script>
<script type=\"text/javascript\"
src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">
</script>
<?php
}
// now we continue with PHP
?>
There are many ways of adding Google's script. It depends on how you are using PHP in your site.
[edited by: HarryM at 12:16 pm (utc) on July 30, 2007]
[edited by: jatar_k at 7:48 pm (utc) on July 30, 2007]
[edit reason] no urls thanks [/edit]
There are plenty of open source editors out there as well as WYSIWYG editors to help you get started. Also, have a look at the PHP Forum Library [webmasterworld.com] on tips to get started using PHP [webmasterworld.com].