PHP Web Site Counter?

Joined
Apr 3, 2023
Messages
3
Reaction score
0
Greetings.
I have tried numerous routines to get a web site counter to work but still
no count. In O'REILLY "Programming PHP" they show embedding PHP directly
into the HTML file. I tried that but to no avail. Perhaps someone could look at the
source code and see what I am doing wrong? http://www.bobbear.org/TestWebSite/TestWebSite.html
thanks in advance
 
Joined
Sep 4, 2022
Messages
136
Reaction score
16
hello HarryA,

php opening pattern is : <?php //your code here; ?>

you use the comment for JS and Html

PHP:
<?php
    $count = 0;

    if(file_get_contents("hitcount.txt") != null){
        $count = file_get_contents("hitcount.txt")
    }

     echo $count;

     $handle = fopen("hitcount.txt", "w+");
     fwrite($handle, ++$count);
     fclose($handle);
     unset($handle);

?>
 
Last edited:
Joined
Apr 3, 2023
Messages
3
Reaction score
0
Thanks. But I remain confused, why didn't

<?php echo 'This better show up or I will be mad' ?>

display the text: "This better show up or I will be mad" ?
As it is right out of the book.
 
Joined
Sep 4, 2022
Messages
136
Reaction score
16
  • see in Php settings, how quotes are set.
  • always end your php instructions by ";" !!!!!!
 
Joined
Apr 3, 2023
Messages
3
Reaction score
0
I copied that verbatim out of the book. :mad: Adding the ; did not help. I have tried at least ten times with external php files and includes also. On the server the HTML file and the hitcount.txt are at 777. The directory at 755 it will not take 777. Perhaps the server hates me. Anyway I give up! I will lower by low standards even lower and try Perl (as a C programmer).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,057
Messages
2,570,443
Members
47,113
Latest member
XZJMike318

Latest Threads

Top