On Tue, Dec 04, 2007 at 10:25:09AM -0000, sagr wrote:
Hi folks.
A very dumb question from a HTML / PHP beginner...
I have written a simple hit counter prog which I can access by running: http://www.suffolk-ancestor-genealogy-research.co.uk/counters/counter.php?we...
I now want to integrate this into a HTML website page, so that this remote script "counter.php" is run and the result displayed on the HTML webpage each time the page is viewed.
I have created a simple HTML page: http://www.suffolk-ancestor-genealogy-research.co.uk/counters/count_page.htm...
which just consists of:
<HTML> <BODY> <script src="http://www.suffolk-ancestor-genealogy-research.co.uk/counters/counter.php?webpage=main"></script> </BODY> </HTML>
When I go to this count_page.html webpage the hit counter is incremented but the result is not displayed on the webpage (even though it's output is visible when I run the script counter.php directly).
<script> doesn't do what you appear to think it does. It points to a location for a javascript file (or other supported scripting language), you are not getting back a javascript file, you're getting some numbers.
You should be able to do something like: <script language="javascript"> url = "http://www.suffolk-ancestor-genealogy-research.co.uk/counters/counter.php?we..." reqObj = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP.3.0"); reqObj.open("GET", url, false); reqObj.send(""); count = reqObj.responseText(); document.write(count); </script>
Or... you could use something like SSI to call it.
Cheers,