Inserting Adsense code inside php page

Discussion in 'PHP' started by calmer, Jul 30, 2009.

  1. #1
    Hello,

    I have a site using php, I want to post adsense code or any java script inside home page blocks, I searched more and I found that is to insert java script this way, that needs : (echo) at the first of any lines that JavaScript consist of.

    I tried that but it failed ..is there any one who can inform me about how to do that

    Thanking you ... !!!
     
    calmer, Jul 30, 2009 IP
  2. PHPGator

    PHPGator Banned

    Messages:
    4,437
    Likes Received:
    133
    Best Answers:
    0
    Trophy Points:
    260
    #2
    That is probably true, there are actually two ways you could do this.

    Try this first and see if it gives you any errors (i doubt it will).

    
    ?>[I][COLOR="red"]PLACE YOUR JAVASCRIPT CODE HERE[/COLOR][/I]<?php
    
    Code (markup):
    Or this:

    
    echo('[I][COLOR="Red"]PLACE YOUR JAVASCRIPT CODE HERE[/COLOR][/I]');
    
    Code (markup):
    Keep the single quotations, send the error if you are getting one.
     
    PHPGator, Jul 30, 2009 IP
  3. calmer

    calmer Peon

    Messages:
    179
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks so much , the second method success..
     
    calmer, Jul 30, 2009 IP
  4. calmer

    calmer Peon

    Messages:
    179
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Can I use the same methods in (html) code ??
     
    calmer, Jul 30, 2009 IP
  5. cray820

    cray820 Peon

    Messages:
    140
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You can use either the "include" or the "require" command. I'm just learning php but I'm not new to coding.
     
    cray820, Jul 30, 2009 IP
  6. zandigo

    zandigo Greenhorn

    Messages:
    71
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #6
    Well in html, you just need to paste whatever Adsense gives you in your code, there is no need to add anything.
     
    zandigo, Jul 30, 2009 IP
  7. calmer

    calmer Peon

    Messages:
    179
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thanks for all of you, it worked ... !!! what I meant by (html) code is : (html) inside (php) code.

    Zandigo : yes to add adsense code in (html) there is no need to add anything.
     
    calmer, Jul 30, 2009 IP
  8. ascensions

    ascensions Active Member

    Messages:
    175
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #8
    Probably a better way would be:


    $adsense=<<<EOD
    
    {adsense code}
    
    EOD;
    
    echo $adsense;
    Code (markup):
     
    ascensions, Aug 1, 2009 IP