I posted a similar question earlier today, however I recently downloaded xampp and can now get syntax errors. I'm very new to all of this.
Please see this example to see the current state of my .php file: http://rich2233.comoj.com/file2.php
I can get the .txt file to extract and display the content from the .txt file, but any attempt of modifying the .txt file does not happen.
When I ran this on xampp, I got this error: Invalid argument supplied for foreach() in file2.php on line 30
Try:
I suspect $users === false as you aren't using the same "calculated" file name.
Here's a quick tip: keep track of your iterator. Confusing? Think of each row number as unique offset in the file. You need to iterate (
foreach
) and increment it by +1 each time. When you're editing a row later on, you just need to submit the offset number, iterate again and check if$i == $_POST['iterator']
.After your most recent update of the code: The answer to the error message in the question title is:
The code is missing the line
$users = file("test.txt");
Edited as that last function wouldn't have worked
If you are planning to use this for something other than just an exercise I suggest using a database.