User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 392,043 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,267 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 928 | Replies: 16
Reply
Join Date: Jan 2008
Posts: 9
Reputation: AP1 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
AP1 AP1 is offline Offline
Newbie Poster

Newby to PHP here.... (Google Analytics)

  #1  
Jan 31st, 2008
RE:Google Analitcs

Hi gang,

I'm new to PHP... as you will probably be able to easily recognize by my following dialog. ;-)

Anyway... I am taking over a website written in PHP with dreamweaver CS3.

It has a seperate footer.php file in a sub directory
and I believe this makes it a dynamic site? Am I wrong?

It appears Google provides two codes for google analytics tracking. Static and dynamic

http://www.google.com/support/analyt...n&answer=55504

Utilizing the the dynamic code..... I get this error at the bottom of my pages.

Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/content/B/r/1/Hidden/html/-APPI-/NAV/footer.php on line 26


HELP.... :-(

Footer.php looks like this (located in a subdirectory)
************************
<?php

echo "
<br />
</td>
</tr>
<tr>
<td align=\"right\" ></td>
<td align=\"right\" valign=\"top\">
<table style=\"margin-left:15px;border-style:solid;border-width:2px;border-color:#000000\" width=\"580\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"336699\" height=\"20\" bordercolor=\"#000000\">
<tr>
<td>
<div align=\"center\"><font color=\"#FFFFFF\" face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\">&copy;
Allied Power Products, Inc.</font></div>
</td>
</tr>
</table>
<div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><b><br>
CAUTION:</b> The final determination as to the suitability of<br>
this product for any purpose is solely that of the user.<br>
Our products are not to be used to lift or move<br>
people or to lift anything over people.</font></div>
</td>
</tr>
<?php
$virtual_page = "Main_Page"
include_once "analyticstracking.php" ?>"
</body>
</html>
";

?>


Analytics.php looks like this
************************
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>

<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-500580");
pageTracker._trackPageview('');
</script>
<?php
// End Analytics tracking code
?>

</body>
</html>
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2008
Posts: 9
Reputation: AP1 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
AP1 AP1 is offline Offline
Newbie Poster

Re: Newby to PHP here.... (Google Analytics)

  #2  
Jan 31st, 2008
Line 26 is: $virtual_page = "Main_Page"
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 238
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: Newby to PHP here.... (Google Analytics)

  #3  
Jan 31st, 2008
Actually, its not $virtual_page="Main_Page". Its because, You have opened the double quote and you are closing it at the end. (after </html>). And you are having a php tag within a php tag !
  1. <?php
  2.  
  3. echo "
  4. <br />
  5. </td>
  6. </tr>
  7. <tr>
  8. <td align=\"right\" ></td>
  9. <td align=\"right\" valign=\"top\">
  10. <table style=\"margin-left:15px;border-style:solid;border-width:2px;border-color:#000000\" width=\"580\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"336699\" height=\"20\" bordercolor=\"#000000\">
  11. <tr>
  12. <td>
  13. <div align=\"center\"><font color=\"#FFFFFF\" face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\">&copy;
  14. Allied Power Products, Inc.</font></div>
  15. </td>
  16. </tr>
  17. </table>
  18. <div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><b><br>
  19. CAUTION:</b> The final determination as to the suitability of<br>
  20. this product for any purpose is solely that of the user.<br>
  21. Our products are not to be used to lift or move<br>
  22. people or to lift anything over people.</font></div>
  23. </td>
  24. </tr>";
  25. <?php
  26. $virtual_page = "Main_Page";
  27. include_once "analyticstracking.php";
  28. echo "</body>
  29. </html>";
  30. ?>
This will probably do.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Jan 2008
Posts: 9
Reputation: AP1 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
AP1 AP1 is offline Offline
Newbie Poster

Re: Newby to PHP here.... (Google Analytics)

  #4  
Jan 31st, 2008
Thank you for your code. I inserted it in and... alas.... I still have an error. This time it at line 25....

Error on the bottom of all pages

Parse error: parse error, unexpected '?' in /home/content/B/r/1/Hidden/html/-APPI-/NAV/allied_footer.php on line 25
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 238
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: Newby to PHP here.... (Google Analytics)

  #5  
Jan 31st, 2008
And what is in allied_footer.php ?

Dang. I did a stupid mistake.
  1. <?php
  2.  
  3. echo "
  4. <br />
  5. </td>
  6. </tr>
  7. <tr>
  8. <td align=\"right\" ></td>
  9. <td align=\"right\" valign=\"top\">
  10. <table style=\"margin-left:15px;border-style:solid;border-width:2px;border-color:#000000\" width=\"580\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"336699\" height=\"20\" bordercolor=\"#000000\">
  11. <tr>
  12. <td>
  13. <div align=\"center\"><font color=\"#FFFFFF\" face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\">&copy;
  14. Allied Power Products, Inc.</font></div>
  15. </td>
  16. </tr>
  17. </table>
  18. <div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><b><br>
  19. CAUTION:</b> The final determination as to the suitability of<br>
  20. this product for any purpose is solely that of the user.<br>
  21. Our products are not to be used to lift or move<br>
  22. people or to lift anything over people.</font></div>
  23. </td>
  24. </tr>";
  25. $virtual_page = "Main_Page";
  26. include_once "analyticstracking.php";
  27. echo "</body>
  28. </html>";
  29. ?>

Check now.
Last edited by nav33n : Jan 31st, 2008 at 2:01 pm.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Jan 2008
Posts: 9
Reputation: AP1 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
AP1 AP1 is offline Offline
Newbie Poster

Re: Newby to PHP here.... (Google Analytics)

  #6  
Jan 31st, 2008
I do appreciate your work.... Still seem to be getting this same funny error.

Parse error: parse error, unexpected '?' in /home/content/B/r/1/Hidden/html/-APPI-/NAV/allied_footer.php on line 25

FYI... allied_footer.php is the actual name of the footer file. I just referred to it as footer.php earlier to reduce confusion. I will stick with calling it allied_footer.php from now on.

Keep in mind, my "allied_footer.php" is in a sub directory. The analyticstracking.php is in the main directory. Let me know if this is an issue. Thank you!
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 238
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: Newby to PHP here.... (Google Analytics)

  #7  
Jan 31st, 2008
Can you show us whats in allied_footer.php ? and yep, dont forget code tags.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Jan 2008
Posts: 9
Reputation: AP1 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
AP1 AP1 is offline Offline
Newbie Poster

Re: Newby to PHP here.... (Google Analytics)

  #8  
Jan 31st, 2008
Hi Nav,

I actually pasted your code, with nothing else, directly into allied_footer.php. So there is nothing but what you provided me at the moment.

I hope this is what you were asking??? I'm ready to provide info when you need it.... Thank you....
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 238
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: Newby to PHP here.... (Google Analytics)

  #9  
Jan 31st, 2008
Okay! I checked what I had posted here and its working fine. Can you also post the code of analyticstracking.php ?
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Jan 2008
Posts: 9
Reputation: AP1 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
AP1 AP1 is offline Offline
Newbie Poster

Re: Newby to PHP here.... (Google Analytics)

  #10  
Jan 31st, 2008
Here ya go... (FYI: I hid my tracking ID)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>

<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-******");
pageTracker._trackPageview('');
</script>
<?php
// End Analytics tracking code
?>

</body>
</html>
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Other Threads in the PHP Forum

All times are GMT -4. The time now is 11:15 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC