0

So the PHP program is supposed to take the user input and save it in a text file called "guest_list" but I am getting these error messages:

Warning: file_put_contents(guest_list.txt): failed to open stream: Permission denied in /Applications/XAMPP/xamppfiles/htdocs/lecture2/welcome.php on line 44

Warning: file_put_contents(guest_list.txt): failed to open stream: Permission denied in /Applications/XAMPP/xamppfiles/htdocs/lecture2/welcome.php on line 45

Warning: file_put_contents(guest_list.txt): failed to open stream: Permission denied in /Applications/XAMPP/xamppfiles/htdocs/lecture2/welcome.php on line 46

Warning: file_put_contents(guest_list.txt): failed to open stream: Permission denied in /Applications/XAMPP/xamppfiles/htdocs/lecture2/welcome.php on line 47

Any help would be greatly appreciated.

Code Part 1

Code Part 2

Qirel
  • 25,449
  • 7
  • 45
  • 62
Jon Doe
  • 37
  • 2
  • 2
  • 8
  • Have you made sure that it has read/write access to the file in question? – Jamie Harding Mar 08 '17 at 02:42
  • how would I do that? – Jon Doe Mar 08 '17 at 02:44
  • 2
    By learning some Linux – RiggsFolly Mar 08 '17 at 02:45
  • 3
    You get "*Permission denied*", so that file doesn't have write-access. If you do `echo fileperms($file);`, what code do you get back? And btw, next time - please don't post images of code. Code is text, and we like it that way. :-) – Qirel Mar 08 '17 at 02:46
  • You could look at PHP CHMOD as an alternative to change permissions to the file if it exists (not recommended): http://php.net/manual/en/function.chmod.php – Jamie Harding Mar 08 '17 at 02:49
  • Sorry, I tried to but I kept getting format errors. Anyway I got "33188" when I threw it in my code. – Jon Doe Mar 08 '17 at 02:51
  • Possible duplicate of [Giving PHP write permission in Apache](http://stackoverflow.com/questions/5357781/giving-php-write-permission-in-apache) – LF00 Mar 08 '17 at 03:26

0 Answers0