Php Echo Google Adsense Code With Styling??

Discussion in 'PHP' started by Squiggs, Jan 29, 2013.

  1. #1
    Hi everyone, I am in need of some urgent help here.

    I have been working on some code that shows google ads to guests but only under the first post on my forum. I have this working but want to add CSS styling to it.

    I need the styling to be within the <?php ?> tags so it only shows for guests and only under the first post, if I put surrounding div tags it puts styling under every post and I dont want that.

    Here is the code so far
    <?php if ($pun_user['is_guest'] == '1' && $post_count == '1') echo '
    <script type="text/javascript"><!--
    google_ad_client = "ca-pub-6495445176343776";
    /* After First Post */
    google_ad_slot = "9383224376";
    google_ad_width = 728;
    google_ad_height = 90;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>' ?>
    Code (markup):
    Help is appreciated :D
     
    Squiggs, Jan 29, 2013 IP
  2. Squiggs

    Squiggs Member

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #2
    Basically all I'm after is where to place the div so the styling is only applied if the conditions are met and so it doesnt cause an error.
     
    Squiggs, Jan 29, 2013 IP
  3. Dangy

    Dangy Well-Known Member

    Messages:
    841
    Likes Received:
    25
    Best Answers:
    2
    Trophy Points:
    155
    #3
    add a brackets your also missing your ending ";" after your echo. You also don't need to use <?php you can just use <?
     
    Dangy, Jan 29, 2013 IP
  4. ogah

    ogah Member

    Messages:
    60
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #4
    beter use <?php
     
    ogah, Jan 30, 2013 IP
  5. Squiggs

    Squiggs Member

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #5
    Thanks Guys, sorted it out.
    <?php if ($pun_user['is_guest'] == '1' && $post_count == '1') echo '
    <div style="clear:both; margin-bottom: 3px;"><div class="adblock1"><script type="text/javascript"><!--
    google_ad_client = "ca-pub-6495445176343776";
    /* After First Post */
    google_ad_slot = "9383224376";
    google_ad_width = 728;
    google_ad_height = 90;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script></div></div>'; ?>
    Code (markup):
     
    Squiggs, Jan 30, 2013 IP