Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Błąd podczas odczytu z pliku?
-raymon-
post
Post #1





Goście







Witam (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Mam taki kod:
  1. <?php
  2. $tablica=file("wyrazy.txt");
  3. foreach($tablica as $key => $wyraz){
  4. $tresc="czesc";
  5. $fd = fopen("$wyraz.html", 'w');
  6. fwrite($fd, $tresc);
  7. fclose($fd);
  8. }
  9.  
  10. ?>

Ma on utowrzyć pliki html, a nazwy dla nich ma pobrać z pliku tekstowego wyrazy.txt, jednak problem polega na tym że pobiera mi tylko ostatni wyraz w pliku tekstowym, i wyskakuje taki błąd:
Cytat
Warning: fopen(plik-drugi .html) [function.fopen]: failed to open stream: Invalid argument in c:\wamp\test\index.php on line 5
Warning: fwrite(): supplied argument is not a valid stream resource in c:\wamp\test\index.php on line 6
Warning: fclose(): supplied argument is not a valid stream resource in c:\wamp\test\index.php on line 7
Warning: fopen(plik-trzeci.html) [function.fopen]: failed to open stream: No such file or directory in c:\wamp\test\index.php on line 5
Warning: fwrite(): supplied argument is not a valid stream resource in c:\wamp\test\index.php on line 6
Warning: fclose(): supplied argument is not a valid stream resource in c:\wamp\test\index.php on line 7

O co z tym chodzi?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
nowotny
post
Post #2





Grupa: Zarejestrowani
Postów: 875
Pomógł: 122
Dołączył: 2.02.2008

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


Wiersze pobrane z pliku zawierają znaki końca lini... jak wiadomo, nazwa pliku nie może zawierać znaku końca lini... użyj trim" title="Zobacz w manualu PHP" target="_manual na zmiennej $wyraz...
Go to the top of the page
+Quote Post

Posty w temacie


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: 3.10.2025 - 09:23