Jump to content

[SOLVED] Function problem ?


nesiak

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/51829-solved-function-problem/
Share on other sites

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 .";
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.