PHP- Please help

Discussion in 'PHP' started by georgechristodoulou, Dec 1, 2006.

  1. #1
    i want to add google analytics code into my site as follows

    <?
    <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
    </script>
    <script type="text/javascript">
    _uacct = "UA-998977-1";
    urchinTracker();
    </script>
    ?>
    PHP:
    will this work?
    Thanks
     
    georgechristodoulou, Dec 1, 2006 IP
  2. cellularnews

    cellularnews Peon

    Messages:
    246
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Nope.

    Why are you surrounding it with PHP tags, when you should just insert it as normal HTML into the webpage.

    If it must be inserted via a PHP command, then use the echo or print commands to do so.
     
    cellularnews, Dec 1, 2006 IP
  3. lv211

    lv211 Peon

    Messages:
    168
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Here's an example of what cellularnews was talking about. This is the phoogle maps script.

    Notice how he uses $map->printGoogleJS(); to inject the google javascript code into his document. You could do something similar except put it somewhere in the body tag instead of the head tag.

    <?php
    /**
    * Showing 1 point with Phoogle Maps
    * class developed by Justin Johnson <justinjohnson@system7designs.com>
    */
    
    require_once 'phoogle.php';
    
    $map = new PhoogleMap();
    $map->setAPIKey("ABQIAAAA0ksKqHM3yT_xmOPe0DANGRRMlCWGe88WcLmN582t1mFB9gpW6hTvRlzTS-LCJ8nFoD2AGi5vq0X-Yg");
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <? $map->printGoogleJS(); ?>
       </head>
      <body>
      <?
     
      $map->addAddress('208 Dingler Ave, Mooresville, NC 28115');
      $map->showMap();
    
      ?>
        </body>
    
    </html>
    Code (markup):
     
    lv211, Dec 1, 2006 IP
  4. dberube

    dberube Active Member

    Messages:
    319
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #4
    remove <? and ?>
     
    dberube, Dec 4, 2006 IP