Re: Php warning message

From: Date: Wed, 20 Feb 2008 23:40:17 +0000
Subject: Re: Php warning message
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-269755@lists.php.net to get a copy of this message
On Feb 20, 2008, at 1:29 PM, "Yuval Schwartz" <yuval.schwartz@gmail.com> wrote:
Hello and thank you, Another question, I get a message: *Warning*: feof(): supplied argument is not a valid stream resource in * /home/content/t/h/e/theyuv/html/MessageBoard.php* on line *52* ** And I've tried troubleshooting for a while; I'm pretty sure I'm opening the file handle correctly and everything but I can't get feof or similar functions like fgets to work. Here is my code if you're interested (it's so that I color every 2nd line in the text): *$boardFile = "MessageBoard.txt"; $boardFileHandle = fopen($boardFile,"r"); for ($counter = 1; !feof($boardFileHandle); $counter += 1) { $colorLine = fgets(boardFilehandle); if ($counter % 2 == 0) { echo "<font color='00ff00'>$colorline</font>"; } else { echo $colorline; }
The loop looks ugly :/ $colored = false; while (!feof($boardFileHandle)) {
    $line = fgets($boardFileHandle);
    if ($colored)
        echo '<span class="colored">', $line, '</span><br />';
    else
        echo $line, '<br />';
    $colored = !$colored;
}
} fclose($boardFileHandle);* Thank you


« previous php.general (#269755) next »