homepage Welcome to WebmasterWorld Guest from 184.73.52.98
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Google Analytics and PHP - bad combination?
Either Google and PHP don't play nice, or I'm an amateur web developer.
cavemanlawyer15




msg:3419684
 3:54 pm on Aug 11, 2007 (gmt 0)

I'm new to PHP and pulling my hair out trying to get this Analytics code in there. (I'm pretty sure this is a Static PHP site, it barely ever gets updated.)

So the Help Center offered what looked like a pretty good start on how to set this up for PHP:
[google.com...]

1) I created the analyticstracking.php file (updated the account # of course) and just to be safe, I uploaded to both
/public_html AND /public_html/php

2) Next -- I couldn't find anything that looked like a footer, so I had to add this line to every template page:
<?php include_once("analyticstracking.php")?>

And the directions say to add it before the </body> tag. But that's the problem; as far as I can tell, these are the template pages:

/public_html/php/mainSubPage.php
/public_html/php/newsletterSignup.php
/public_html/php/sendGiftCertificate.php
/public_html/php/showCalendar.php
/public_html/php/showDynamicContents.php
/public_html/php/showFeedbackForm.php
/public_html/php/showGuestBook.php
/public_html/php/showMenu.php
/public_html/php/showOrderForm.php
/public_html/php/showPhotos.php
/public_html/php/showPicture.php
/public_html/php/showPictureFrame.php
/public_html/php/showPictureTop.php

3) And here I find two problems.

a) These files don't seem to have </body> tags. Am I wrong in assuming that these are in fact the template files?

b) I backed these up and renamed the originals -- and the site was still reading them! In other words, those with the original filenames were sitting on my hard drive, and the backed up versions had new names that the PHP file ought not to be able to read. But it could!?!?! What gives?

I'm dying here. If anyone knows anything about this, I'd be forever in your debt.

PB

[edited by: jatar_k at 5:16 pm (utc) on Aug. 11, 2007]
[edit reason] no urls thanks [/edit]

 

SixTimesEight




msg:3419731
 5:55 pm on Aug 11, 2007 (gmt 0)

Is your site running a premade CMS?

Your site probably has a couple main files which run the whole show. Those files will contain the </body> tag and only request the necessary template for the content on a given page.

Get a program like notepad++ that can open multiple files in tabs, open up ALL of the files for your website and run a search for the </body> tag in all files at once.

Habtom




msg:3420016
 5:37 am on Aug 12, 2007 (gmt 0)

I backed these up and renamed the originals -- and the site was still reading them! In other words, those with the original filenames were sitting on my hard drive, and the backed up versions had new names that the PHP file ought not to be able to read.

How were they renamed? example.php to example.php.2 won't be an executable PHP file. The correct way to rename it is to put example.php as example2.php.

You might already know this, but that seems to be the reason why the file can't be an executable PHP file after renaming.

SixTimesEight




msg:3420030
 5:55 am on Aug 12, 2007 (gmt 0)

but that seems to be the reason why the file can't be an executable PHP file after renaming.

I didn't get the impression from the post that the files were no longer executable. I got the impression that he renamed the original files and uploaded new versions of them yet nothing seemed to change on the website as if the files hadn't been renamed/edited at all.

I asked if it was a pre-built content management system because some of them have a page caching feature which could create the illusion of old files still being included. However, I don't think any of them will cache a page for more than a few minutes so this explanation seems unlikely.

What is more likely is that the files that are actually being included by the website are not the same ones he is editing.

and just to be safe, I uploaded to both
/public_html AND /public_html/php

You don't need to upload an included file to two places "just to be safe". It's one or the other. Find out which one is the proper location and delete the other one immediately or you will confuse yourself down the road.

Habtom




msg:3420032
 6:11 am on Aug 12, 2007 (gmt 0)

SixTimesEight, reading the post back again, it seems the solution you provided is the most likely one.

as far as I can tell, these are the template pages

And those mentioned as templates, don't sound like they are templates to me.

Get a local copy of the whole site, open it with an editor (Dream Weaver, Zend Editor or anything), and then search for "</body>" as mentioned by SixTimesEight. You might need to look for a logical footer name or open the pages and see what pages they include at the very bottom.

And again like suggested, I can't stress enough on this, never leave copies of the same file in the server for the reasons of safety or anything, keep the site clean as it can allow you to find and edit files easily in the future.

Habtom

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved