Hi,
I have trouble with a little counting function. It wasn't developped by me, the author is not replying to my mail, and my efforts to get help have not yet given any result.
Here is the code of the function:
function countlines($list,$ctr) { if (file_exists($list)) { $lines = file($list); while(list($key, $val) = each($lines)) { if (stristr ($val, "<!-- comment -->")) { $ctr++; } } } if ($ctr > 0)
return("(".$ctr.")");}
this is the line that calls the function:
<a class="comment" href="javascript:void(0);"
onClick="commentPopUp('/comments.php3?comment=<$BlogItemNumber$>');">
comments...<? echo countlines("/comments/<$BlogItemNumber$>.comment",0); ?></a>
(hope the code shows up all right here!)
You can see that all the script does is open the given file in the directory "comments" and count the lines.
You can find more details about my troubles and what I have tried at
http://www.blogger.com/discuss/d.pyra?t=700127&c=689464&ap=last
In short, the function works correctly when it is called from the root directory and with relative urls, but then it does not work in a subdirectory - and I need the code to work in the root AND the subdirectories.
And if I put server-relative urls, as I did, it simply stops working.
Any comments, suggestions, or bright ideas to help me out of this fix are most welcome!
Tara
PS: you can see the pages the script is supposed to work on at
http://www.tarastar.f2s.com/