Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Błąd w trakcie zapisu
Isaac
post
Post #1





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 23.09.2005

Ostrzeżenie: (0%)
-----


Witam, przychodze do was z problemem dotyczącym błędnego zapisu w pliku. Napisałem sobie moduł edycji menu, lecz wielokrotnie skrypt nie potrafi dobrze zapisać pliku.

Wyskakuje mi błąd:

Kod
Warning: fopen(menul.txt): failed to open stream: Permission denied in /home/miten/domains/gothic.funday.pl/acp/edit_menu.php on line 14

Warning: fwrite(): supplied argument is not a valid stream resource in /home/miten/domains/gothic.funday.pl/acp/edit_menu.php on line 15

Warning: fclose(): supplied argument is not a valid stream resource in /home/miten/domains/gothic.funday.pl/acp/edit_menu.php on line 16


Próbowałem rozwiązać ten problem na dwóch serwerach (windowsowym i linuxowym) jednak nic to nie pomogło.

Skrypt przedstawiam poniżej.

  1. <?php
  2.  
  3. if (!empty($_POST['menu']) or !empty($_GET['sv'])){
  4.  
  5. switch($_POST['menu']){
  6. case 'Lewe':  $menu="menul.txt"; break;
  7. case 'Prawe': $menu="menup.txt"; break;
  8. }
  9.  
  10. if ($_POST['menu'] and $_POST['dane'] and $_GET[opm]=="zmien"){
  11.  
  12.  
  13.  
  14. $a=fopen($_POST['menu'], "w");
  15. fwrite($a, $_POST['dane']);
  16. fclose($a);
  17. if ($a==TRUE){
  18. echo('Zapis zakończony sukcesem.');
  19. }else{echo('Zapis nie powiódł się.');}
  20.  
  21. }
  22.  
  23. $a=fopen($menu, "r");
  24. $dane=fread($a, filesize($menu));
  25.  
  26.  
  27.  
  28. echo('<form action="?idd=acp&op=edit_menu&opm=zmien" method="POST">
  29. <input type="hidden" value="'.$menu.'" name="menu">
  30. <textarea class="textarea" name="dane" cols="69" rows="20">'.$dane.'</textarea>
  31.  
  32. <br /><br />
  33. <center><input type="submit" value="Zapisz" class="textarea"></center>
  34. </form>
  35. ');
  36.  
  37.  
  38.  
  39. }
  40.  
  41. else{
  42.  
  43.  
  44. echo('Które menu chciałbyś zedytować?');
  45.  
  46. echo('<form action="?idd=acp&op=edit_menu" method="POST">
  47. <input type="radio" name="menu" value="Lewe">&nbsp;&nbsp;Lewe
  48. <br />
  49. <input type="radio" name="menu" value="Prawe">&nbsp;&nbsp;Prawe
  50. <br /><br />
  51. <center><input type="submit" value="wyświetl" class="textarea"><input type="reset" value="wyczyść" class="textarea"></center>
  52. </form>');
  53. }
  54.  
  55. ?>

(IMG:http://forum.php.pl/uwaga.gif)
poprawiam
---
nospor


Ten post edytował nospor 31.03.2006, 13:29:26
Go to the top of the page
+Quote Post
zbig13
post
Post #2





Grupa: Zarejestrowani
Postów: 214
Pomógł: 0
Dołączył: 3.04.2004
Skąd: Legionowo

Ostrzeżenie: (0%)
-----


Jak mówi sam błąd - nie masz uprawnień do zapisu w tym katalogu. Ustaw chmoda na 666, ewentualnie 777 i powinno działać.
Go to the top of the page
+Quote Post
Isaac
post
Post #3





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 23.09.2005

Ostrzeżenie: (0%)
-----


Na windzie nie ma chmodów, a na linuxie już dawno miałem ustawione 777 (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

Ten post edytował Isaac 31.03.2006, 20:44:58
Go to the top of the page
+Quote Post
Apo
post
Post #4





Grupa: Zarejestrowani
Postów: 426
Pomógł: 1
Dołączył: 2.10.2005

Ostrzeżenie: (0%)
-----


może tak:

  1. <?php
  2.  
  3. if (!empty($_POST['menu']) or !empty($_GET['sv'])){
  4.  
  5. switch($_POST['menu']){
  6. case 'Lewe': $menu="menul.txt"; break;
  7. case 'Prawe': $menu="menup.txt"; break;
  8. }
  9.  
  10. if ($_POST['menu'] and $_POST['dane'] and $_GET['opm']=="zmien"){
  11. if(!file_exists($_POST['menu']))
  12. {
  13. echo 'plik nie istnieje';
  14. }
  15. $a=fopen($_POST['menu'], "w");
  16. flock($a, 3);
  17. fwrite($a, $_POST['dane']);
  18. flock($a, 1);
  19. fclose($a);
  20. if ($a===TRUE) echo('Zapis zakończony sukcesem.');
  21. else echo('Zapis nie powiódł się.');
  22.  
  23. }
  24.  
  25. $a=fopen($menu, "r");
  26. $dane=fread($a, filesize($menu));
  27.  
  28.  
  29. echo '<form action="?idd=acp&op=edit_menu&opm=zmien" method="POST">
  30. <input type="hidden" value="'.$menu.'" name="menu">
  31. <textarea class="textarea" name="dane" cols="69" rows="20">'.$dane.'</textarea>
  32. <br /><br />
  33. <center><input type="submit" value="Zapisz" class="textarea"></center>
  34. </form>';
  35.  
  36. }
  37.  
  38. else{
  39.  
  40. echo 'Które menu chciałbyś zedytować?
  41. <form action="?idd=acp&op=edit_menu" method="POST">
  42. <input type="radio" name="menu" value="Lewe">&nbsp;&nbsp;Lewe
  43. <br />
  44. <input type="radio" name="menu" value="Prawe">&nbsp;&nbsp;Prawe
  45. <br /><br />
  46. <center><input type="submit" value="wyświetl" class="textarea"><input type="reset" value="wyczyść" class="textarea"></center>
  47. </form>');
  48. }
  49. ?>
Go to the top of the page
+Quote Post
Isaac
post
Post #5





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 23.09.2005

Ostrzeżenie: (0%)
-----


Hmm...

Kod
Warning: fopen(menul.txt): failed to open stream: Permission denied in /home/miten/domains/gothic.funday.pl/public_html/menu/acp/edit_menu.php on line 17

Warning: flock(): supplied argument is not a valid stream resource in /home/miten/domains/gothic.funday.pl/public_html/menu/acp/edit_menu.php on line 18

Warning: fwrite(): supplied argument is not a valid stream resource in /home/miten/domains/gothic.funday.pl/public_html/menu/acp/edit_menu.php on line 19

Warning: flock(): supplied argument is not a valid stream resource in /home/miten/domains/gothic.funday.pl/public_html/menu/acp/edit_menu.php on line 20

Warning: fclose(): supplied argument is not a valid stream resource in /home/miten/domains/gothic.funday.pl/public_html/menu/acp/edit_menu.php on line 21
Zapis nie powiódł się.
Notice: Use of undefined constant haslo - assumed 'haslo' in /home/miten/domains/gothic.funday.pl/public_html/menu/acp/acp.php on line 60

Notice: Use of undefined constant group - assumed 'group' in /home/miten/domains/gothic.funday.pl/public_html/menu/acp/acp.php on line 62

Notice: Use of undefined constant m - assumed 'm' in /home/miten/domains/gothic.funday.pl/public_html/menu/acp/acp.php on line 65

Notice: Use of undefined constant d - assumed 'd' in /home/miten/domains/gothic.funday.pl/public_html/menu/acp/acp.php on line 70
Witaj Isaac. Zostałeś zalogowany dnia 31 marca
Notice: Use of undefined constant Y - assumed 'Y' in /home/miten/domains/gothic.funday.pl/public_html/menu/acp/acp.php on line 86

Notice: Use of undefined constant H - assumed 'H' in /home/miten/domains/gothic.funday.pl/public_html/menu/acp/acp.php on line 86
Go to the top of the page
+Quote Post
erix
post
Post #6





Grupa: Moderatorzy
Postów: 15 467
Pomógł: 1451
Dołączył: 25.04.2005
Skąd: Szczebrzeszyn/Rzeszów




Cytat
na windzie


1: to co w sciezkach robi /home?
2: na jakiego typu partycji masz pliki strony? Jak na NTFS-ie, to sprawdz uprawnienia dla uslugi serwera.

Ten post edytował erix 31.03.2006, 21:56:08
Go to the top of the page
+Quote Post
Isaac
post
Post #7





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 23.09.2005

Ostrzeżenie: (0%)
-----


To co powyżej testowałem na linuxie (gothic.funday.pl), natomiast wcześniej sprawdzałem na serwerze gram i też nie działało.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 15.09.2025 - 13:45