Hi Mark,
Based on the OP's choice of Subject ("... *remote* PHP script...") I assume that the calling code should not be assumed to be on the same server, and therefore should not be assumed to be running PHP
Correct. The calling code will sometimes be located on non PHP webspace so must work from within a basic HTML page.
(although clearly in the OP's example the host is the same).
I just put the calling code page on our server to provide a test example in case ALUGers wanted to run it.
It looks like an attempt to build a fairly standard counter script (a good way to learn some PHP, by the way).
Yes, I am trying to learn PHP. We use 3rd Party Hit Counters at the moment but they are very fragmented with each website having it's own separate hit counter (and in some cases individual pages having their own counters). I am aiming to organise this chaos and have all our individual websites report their counts to a single central admin website directory so I can, when I gain the skill, do some more detailed overall analysis of visitor patterns across our various websites using just one database.
Brett's Javascript is the best way to do this without changing the counter script, IMHO.
Yes, his suggestion was very helpful (but a little beyond my understanding at the moment).
On the other hand, assuming that changing the counter script is OK
Yes.
I am guessing that the script ends something like: echo $counter; .. which could be replaced by...
if (!empty($_GET['js'])) echo "document.write($counter);"; else echo $counter;
Thanks for that idea which I have now implemented.
.. then change the HTML from:
<script src="http://www.suffolk-ancestor-genealogy-research.co.uk/counters/counter.php?webpage=main"></script>
.. to ..
<script src="http://www.suffolk-ancestor-genealogy-research.co.uk/counters/counter.php?js=1&webpage=main"></script>
That way, whether or not it outputs the script instead of the raw value is configurable depending on the parameters passed to the counter script.
Excellent! Works a treat!
Thanks to everyone for their helpful tips and suggestions.
Sagr.