Hi,

that script works on my server.
What do you get if you add this line in front of the fread line:

echo "file size: ".filesize($count)."<br>\n"

Thomas

    may i ask what the fread line is and how this fixes it? out of curiosity i dont doubt you but you know i just want to know what was wrong

      This is part of the code in counter.php

      // get the current hit count
      $fp_count = fopen($file, "r");
      $count = fread($fp_count, filesize($file));
      fclose($fp_count);

      The error message you posted
      Warning: fread(): Length parameter must be greater than 0. in /home/liberi/public_html/ragnarok/counter.php on line 20

      meant that the second parameter of fread was 0. So I assume that the file count.txt was empty. I think it that it existet at all because fopen was successful.

      I tried the counter.php script with a count.txt file which just contained a 0 and the counter worked without any problems on my server.

      While writing this I testet the code with an empty count.txt file and the counter didn't work.
      Hmm ... seems like the counter script doesn't like any line feeds in the count.txt file. So to initialize the count.txt file execute the following command on the shell:

      echo -n 0 > count.txt

      Then set the permissions of that file so that the web server can write to it.

      That counter.php script definitively needs some tweaking...

      Thomas

        oh man, this just isnt working 🙁 , so i put that at the end of my script

        but that didnt really work either. and then i tried other scripts and they all give me thes same problem. exactly. nothing past 1. do you have aim or something? i just dont understand and i might be readin you wrong

        {
        	// get a digit from the hit count
        	$digit = substr("$count", $i, 1);
        
        // print the image for that digit
        echo "<img src=images/digits/$digit.$imgExtension>";
        }
        
        echo -n 0 > count.txt 
        
        ?>

          Sorry,

          I wasn't clear enough about the echo ...

          Leave the code as it is in the counter.php script and execute that echo line on a shell (telnet/ssh to the server and change to the directory where count.txt is).

          Alternatively create a PHP script that does something like

          <?PHP
          system("echo -n 0 > count.txt");
          ?>
          

          Place it in the directory where count.txt is and execute it once.

          Thomas

            oh god i feel so guilty a'bout having you helping me this long but you cant fathom how grateful i am. but there are still two questons i have. i have access to my cpanel but i've never used it to actually edit the shell in 🙁 and i dont know if i can do that in phpmyadmin either. also whe nyou say directory you mean something like this /home/liberi/public_html/ragnarok/count.txt right?

              Yes,

              that directory. Did you try to create a PHP script that just executes that command with e.g. the system or passthru command ?

              Thomas

                not yet, is the shell command mandatory before i do that?

                  I tried to use that counter and found out that the file count.txt had to contain at least a 0. I then created the file with an editor. After that the script contained a 0 with a line feed.

                  The counter doesn't work properly if that file contains anything else than that digits (like e.g. \r or \r\n).

                  Try the file I attached to this post (zipped, don't edit the file)

                  I wonder if there are better counter scripts out there ... no, I'm pretty sure 😉

                  Thomas

                    hmm, man i cant believe it, it iddnt work. again. i think the problem has to do with my php settings or something because every counter i install has teh same problem. do you have aim so we can talk about this quicker ha? if for privacy reasons i understand completely. i cant believe all this for to understand this stupid php glitch.

                      Hi,

                      I am not a customer of AOL and don't have an aim account at all. What about icq ?

                      by the way ... i never asked which server/os/web server/php causes that problems ...

                      Thomas

                        wait, aol people can talk to people on aim. because every aol account comes with a screen name, unless you're using something else really weird. i can do icq. but i'd have to reinstall that. i'm positive aol should come iwth aim

                          Hi,

                          was that the answer to my pm 🙂

                          Thomas

                            Write a Reply...