1

I've programmed a web app for my Family, to regulate the Meals in a week, this website is locally hosted on my new Raspberry Pi. To store the Data (The Meals for everyday) a txt.file is used. I've also programmed a Site where Family members can write what they would like to eat. That site works on my Editor (PHPstorm) perfectly but not on the Raspberry Pi. The Problem on the Raspberry is that there are no changes on the txt. file. I really can't figure out why, because on PHP Storm there is no problem.

That is my Code which stores the data in my txt

$datei=file("essen.txt");
            $fr=$datei[$t];
            $mi=$datei[$t+1];
            $ab=$datei[$t+2];
            $frneu = $_POST["frueh"]."\n";
            $mineu = $_POST["mittag"]."\n";
            $abneu = $_POST["abend"]."\n";
            array_splice($datei, $t, 1, array($frneu));
            array_splice($datei, $t+1, 1, array($mineu));
            array_splice($datei, $t+2, 1, array($abneu));
            $fp=fopen("essen.txt", "w");
            fputs($fp, $datei[0]);
            fclose($fp);
            $fp=fopen("essen.txt", "a");
            for($i=1; $i<count($datei); $i++){
                fputs($fp, $datei[$i]);
            }
            fclose($fp);

I hope someone can help me. Just say I've you need more code

student
  • 11
  • 1
  • The web server user probably does not have write access to the file. On the properties of the file give all write access. To check for errors look in the /var/log/apache2/error.log – Jason K Apr 14 '21 at 21:15
  • Ok thanks for the quick response I will try it soon and tell you I've it worked – student Apr 14 '21 at 21:18

1 Answers1

0

I edited the permissions so that every data source can write on the file thanks to Jason K for helping

student
  • 11
  • 1