[ALUG] How to display result of remote PHP script within a HTML page

Dave Crisp dave at goldeneyes.org.uk
Tue Dec 4 11:40:56 GMT 2007


On Tue, 2007-12-04 at 10:25 +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?webpage=main
> 
> 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.html
> 
> 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).
> 
> How do I get the result from the remote script counter.php to display on my
> count_page.html page?

The HTML <script> tag is for embedding JavaScript; you cant include a
PHP file that way IIRC.

Try renaming the html file to have a .php extension, and then replace
the <script> ... </script> with "<?php
include('http://www.suffolk-ancestor-genealogy-research.co.uk/counters/counter.php?webpage=main'); ?>

Hope this helps.




More information about the main mailing list