I am an antique and I(don't ask why, its an obscure reason) can't make SQL work, so I'm storing usernames in a text file. For some reason, the fopen command is not working more than once in a loop. Please explain, and do NOT mention SQL, unless no one else can come up with another solution. Thanks in advance.
What I am doing is opening a text file, loading the first username, checking if it exist, if not create the file, if so leave it alone, and write the link. The purpose is so that a control panel will be able to add/delete users in a text file, and this php script will load them into a list of users(with the A HREF pointing to their user pages). For some reason the fopen command works only once on the first time through the loop. It will create
firstname%20lastname.htm if it does not exist but nothing else.
$doesexist4 = file_exists("teach_4.txt");
If($doesexist4 == false) {
$teach4new = fopen("teach_4.txt", 'w');
$blanktxt4 = "";
fwrite($teach4new, $blanktxt4);
fclose($teach4new);
}
$teach4 = fopen("teach_4.txt", 'r');
$teach4read = fread($teach4, 1024768);
$teachers4 = strtok($teach4read, ',');
while ($teachers4 !== false) {
echo "<A HREF='$teachers4.htm'>$teachers4</A><BR>";
$doesexistt4 = file_exists("$teachers4.htm");
echo "error on $doesexistt4";
If ($doesexistt4 == false) {
$teachers4new = fopen("$teachers4.htm", 'w');
$blanktxt = "";
fwrite($teachers4new, $blanktxt);
fclose($teachers4new);
}
$teachers4 = strtok(",");
};
where teach4.txt equals "firstname lastname, weird teacher, extra"
the end 🙂