[PHP] Fwrite Function
Hello, Can you please help me, I am writing code where I create a file and write to it from a form on a webpage and then read and display this file on the webpage. I want to change the color of the text that is written to the file. Do you know how I can do this? This is some of my code if you need clarification: * $boardFile = "MessageBoard.txt"; $boardFileHandle = fopen($boardFile,'a') or die("can't open file"); fwrite($boardFileHandle, $name); fwrite($boardFileHandle, $talk); fclose($boardFileHandle); } $boardFile = "MessageBoard.txt"; $boardFileHandle = fopen($boardFile,"r"); $talkR = fread($boardFileHandle, filesize($boardFile)); fclose($boardFileHandle); echo $talkR;* ** ** Thanks
[PHP] Php warning message
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 "$colorline"; } else { echo $colorline; } } fclose($boardFileHandle);* Thank you