Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a windows 8 installation with a wamp-joomla website running on port 80.

Now I have another html site using iis on port 8080. So far so good. Both sites work fine. Apart from the wamp stack installed at c:\wamp, Another PHP install exists at c:\php for use with iis.

The php version can be accessed from another pc on my LAN by typing http://myip:8080/phpinfo.php. The phpinfo.php file resides in the root of website folder.

My homepage uses a reference to a page counter script 'counter.php' also in the same folder. if I type http://myip:8080/counter.php directly, the php file executes, however, there is no output when the same counter.php is embedded in my home page 'index.html'.

contents of 'counter.php' are as under:
PHP
$count_my_page = ("hitcounter.txt");
$fp = fopen($count_my_page , "r");
$hits = file($count_my_page);
$hits[0] ++;
fclose($fp);
$fp = fopen($count_my_page , "w");
fputs($fp , "$hits[0]");
fclose($fp);
echo "Hits ", "$hits[0]", "";
?>


What am I doing wrong ? How can I access the counter script ?

Also when I directly access counter.php, everytime the counter reads 1 only.


My home page calls the counter.php by simply :


include 'counter.php';
?>
Posted
Updated 4-Nov-15 5:47am
v3

1 solution

Check you have read/write permissions to the "hitcounter.txt" file and that the file is in the working directory.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900