Reading from a file
I'm trying to read from a text file "ppl.txt", it's working only for the first line (Player1). If I try with Player2 or with KillerGirl it fails.
I think the the script is reading only the first line. How can I make to read the rest of lines? ppl.txt: Code:
Player1PHP Code:
|
Re: Reading from a file
Instead of using fgets() within the while condition, you should use it within the brackets and use feof() for the condition.
ex: Code:
Code:
|
Re: Reading from a file
PHP Code:
|
Re: Reading from a file
|
Re: Reading from a file
maybe this can help u a little bit
|
Re: Reading from a file
This is why I break the loop:
[IMG]http://img856.**************/img856/7668/86684968.png[/IMG] I used parse because the tutorial: http://forums.alliedmods.net/showpos...96&postcount=1 Flags: Mode uses the standard C library of mode types. The first character can be: "a" - append "r" - read "w" - write The second character can be: "t" - text "b" - binary Thanks ! PHP Code:
|
Re: Reading from a file
Quote:
fgets() is perfectly fine to use as the condition in the loop. @killergirl Use trim() after fgets() so the new line character is removed from the end of the string. |
Re: Reading from a file
Quote:
PHP Code:
|
Re: Reading from a file
OldUserName is not getting set
PHP Code:
|
Re: Reading from a file
Now it's working !
I removed brackets from fgets(), I added trim and I moved the "print to player" function outside controlled by a bool variable. I added a task function to call the "print to player". Thank you for support ! |
| All times are GMT -4. The time now is 14:29. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.