nesiak Posted May 17, 2007 Share Posted May 17, 2007 Hello there, i'm new to this forum as i am new to PHP! This is my code that will output the number of comments and number of posts in a blog i'm trying to create. It doesn't output anything why? <?php function nofcom() { $filee = fopen("comments.php", "r") or exit("Can't open comments file"); //Comments are all one line in height while(!feof($filee)) { fgets($filee); $i++; } fclose($filee); $nofcom == $i; echo "Total comments : $nofcom ."; } function nofart() { $filew = fopen("posts.php", "r") or exit("Can't open news file !"); //A star (*) is marking a beggining of a another post while(!feof($filew)) { fgetc($filew); if (fgetc($filew)=="*") { $o++; } } fclose($filew); $nofcom == $i; echo "Ukupno komentara : $nofcom ."; } ?> Please help Quote Link to comment https://forums.phpfreaks.com/topic/51829-solved-function-problem/ Share on other sites More sharing options...
trq Posted May 17, 2007 Share Posted May 17, 2007 $nofcom == $i; Should be... $nofcom = $i; Quote Link to comment https://forums.phpfreaks.com/topic/51829-solved-function-problem/#findComment-255386 Share on other sites More sharing options...
nesiak Posted May 17, 2007 Author Share Posted May 17, 2007 noup still doesn't output anything ? (i'm using this with include() maybe i'm using it wrong?) <p class="style2"><?php include("status.php") ?></p> There was a another error in my posted code, fixed it too and still it won't output anything to the page ? <?php function nofcom() { $filee = fopen("comments.php", "are") or exit("Can't open comments file"); //Comments are all one line in height while(!feof($filee)) { fgets($filee); $i++; } fclose($filee); $nofcom = $i; echo "Total comments : $nofcom ."; } function nofart() { $filew = fopen("posts.php", "are") or exit("Can't open news file !"); //A star (*) is marking a beggining of a another post while(!feof($filew)) { fgetc($filew); if (fgetc($filew)=="*") { $o++; } } fclose($filew); $nofart = $o; echo "Total articles : $nofcom ."; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/51829-solved-function-problem/#findComment-255407 Share on other sites More sharing options...
taith Posted May 17, 2007 Share Posted May 17, 2007 no... you still have $nofcom == $i; $nofart == $o; them ==s need to be = Quote Link to comment https://forums.phpfreaks.com/topic/51829-solved-function-problem/#findComment-255412 Share on other sites More sharing options...
nesiak Posted May 17, 2007 Author Share Posted May 17, 2007 I fixed those (typo) It should at least output "Total articles :", but it doesn't ? Quote Link to comment https://forums.phpfreaks.com/topic/51829-solved-function-problem/#findComment-255413 Share on other sites More sharing options...
trq Posted May 17, 2007 Share Posted May 17, 2007 I dont see you actually call these functions anywhere. Function dont run by themselves, they need to be called. eg; <?php function foo() { echo "this is foo"; } // call the function. foo(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/51829-solved-function-problem/#findComment-255436 Share on other sites More sharing options...
nesiak Posted May 17, 2007 Author Share Posted May 17, 2007 Yup, just noticed, how stupid of me ! :-X Quote Link to comment https://forums.phpfreaks.com/topic/51829-solved-function-problem/#findComment-255449 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.