Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php]jak zaincluduje plik to wyskakuja błedy
Matiash
post
Post #1





Grupa: Zarejestrowani
Postów: 103
Pomógł: 0
Dołączył: 7.04.2007

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


Witam , otoz mam dziwna sprawe, ktora dotyczy includowania. Posiadam prosta ksiege gosci ktora składa sie z jednego pliku: gueastbook.php i pliku gueastbook.txt gdzie sa dodawane wpisy. Obydwa pliki znajduja sie w folderze ksiega
Otoż gdy wpisze w adresie przegladarki:
http://mojawitrynwa/pliki/ksiega/gueastbook.php - to wszystko działa bez zarzutu natmoiast gdy np chce zaincludowac plik. ksiega.php np w pliku podstrona2.php ktory znajduje sie w folderze pliki to wyskakuja błedy typu :

Warning: file() [function.file]: Unable to access guestbook.txt in /home/t/r/e/trekker/www/pliki/ksiega/guestbook.php on line 28

Warning: file(guestbook.txt) [function.file]: failed to open stream: No such file or directory in /home/t/r/e/trekker/www/pliki/ksiega/guestbook.php on line 28



Warning: file() [function.file]: Unable to access guestbook.txt in /home/t/r/e/trekker/www/pliki/ksiega/guestbook.php on line 57

Warning: file(guestbook.txt) [function.file]: failed to open stream: No such file or directory in /home/t/r/e/trekker/www/pliki/ksiega/guestbook.php on line 57

Warning: array_reverse() [function.array-reverse]: The argument should be an array in /home/t/r/e/trekker/www/pliki/ksiega/guestbook.php on line 58

Warning: Invalid argument supplied for foreach() in /home/t/r/e/trekker/www/pliki/ksiega/guestbook.php on line 59

Moje drzewo folderow wyglada tak : pliki(w tym dolderze znajduja sie rozne podstrony)---->ksiega(w tym folderze znajduja sie pliki guestbook.txt i guestbook.php)

Dodam ze moj plik include wyglada tak:
  1. <?PHP
  2.  include("ksiega/guestbook.php");
  3. ?>


--------------------
www.picture-globe.com
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 8)
strife
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 2 605
Pomógł: 96
Dołączył: 22.10.2004
Skąd: UK

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


Jeśli z katalogu podstron, chcesz zaincludować plik to jest logiczne, że Ci nie zadziała bo w tym katalogu podana przez Ciebie ścieżka nie istnieje, spróbuj w ten sposób:

  1. <?php
  2.  include("../ksiega/guestbook.php");
  3. ?>


?

Pozdrawiam.


--------------------
Go to the top of the page
+Quote Post
Matiash
post
Post #3





Grupa: Zarejestrowani
Postów: 103
Pomógł: 0
Dołączył: 7.04.2007

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


hmmm chyba mnie zle zrozumiales, bowiem jak wpisze Twoj kod to w ogole nawet guestbook.php nie inclduje a jak zainclduje moim sposbem to guesybook.php jest zaincludowany ale wywala bledy o guestbook.txt ( ktory paradoksalnie znajduje sie w tym samym folderze co guestbook.php) co mnie dziwi.

Rozrysuje to tak:

www
index.php
|
|
|
pliki
podstrona1.php
podstrona2.php
|
|
|
ksiega
guestbook.php
guestbook.txt

------------------------------------------
jesli w przegladrce wpisze adres: http://mojawitryna/pliki/ksiega/guestbook.php to wszystko dziala ok

Jesli natomiast w pliku podstrona1.php wpisze taki kod:
  1. <?php
  2.  include("ksiega/guestbook.php");
  3. ?>


to includuje plik guestbook.php ale wywala bledy takie jak opisalem w pierwszym poscie.

Jesli uzyje Twojego kodu to nie includuje nawet guestbook.php


Dodam ze nie tylko z ksiega gosci mam taki bowiem mialem tez inne skrypty tez wyalaja bledy gdy je includuje

Ten post edytował Matiash 12.05.2007, 23:23:29


--------------------
www.picture-globe.com
Go to the top of the page
+Quote Post
cyngiel
post
Post #4





Grupa: Zarejestrowani
Postów: 101
Pomógł: 1
Dołączył: 28.12.2003
Skąd: Gdańsk

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


chcesz, żeby tobie pomóc, a nawet kodu nie zamieściłeś, skoro piszesz, że nie includuje ci guestbook.txt, to zamieść część kodu odpowiedzialną za to, przypuszczam, że to jest jakaś literówka winksmiley.jpg

Ten post edytował cyngiel 12.05.2007, 23:25:00


--------------------
Go to the top of the page
+Quote Post
Matiash
post
Post #5





Grupa: Zarejestrowani
Postów: 103
Pomógł: 0
Dołączył: 7.04.2007

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


No nie wydaje mi sie ze to literowka bowiem jak wpisze adres z przegladarki bezposrednio do pliku guestbook.php to działą ona znakomicie. Natomiast gdy wpisze adres do pliku ktory inclduje guestbook.php to pojawiaja sie bledy. Ponadto zaznaczam izbydwa pliki znajduja sie w folderze ksiega.

Oto fragment kodu ksiegi:
  1. <html>
  2. <body>
  3. <?php
  4. $gbfile = "guestbook.txt"; // The file that all guestbook entrys should be saved in.
  5. $thisfile = "guestbook.php"; // The name of this file.
  6. $dateshow = "Y-m-d - H:i:s"; // Decides how the date should be shown. <a href="http://www.w3schools.com/php/func_date_date.asp" target="_blank">http://www.w3schools.com/php/func_date_date.asp</a>
  7. $username = "user"; // Admin username.
  8. $password = "pass"; // Admin password.
  9. $notlog = "Not logged in!"; // Text to show when the user enters wrong username or password.
  10. $thankstxt = "Thank you for writing in my guestbook!"; // The text that the user will see after entering something in the guestbook.
  11. $errorrequire = "Required fields are name and message!";
  12. $gbedited = "Guestbook has been edited!"; // Text to print out when guestbook has been edited.
  13. $nogbedited = "No entrys selected to be removed!"; // Text to print out when no entrys where selected in admin area.
  14. $smsgstart = "<meta http-equiv="refresh" content="3;URL={$thisfile}" /><p>"; // Start of every message printed out.
  15. $smsgend = "<br />You will be sent back in 3 seconds. If not click <a href="{$thisfile}">here</a></p>"; // End of every message printed out.
  16.  
  17.  
  18. $arr = file($gbfile);
  19. $mdpass = md5($password);
  20. $date = date($dateshow);
  21. $name = htmlentities(strip_tags($_POST['name']));
  22. $email = htmlentities(strip_tags($_POST['email']));
  23. $homepage = htmlentities(strip_tags($_POST['homepage']));
  24. $message = nl2br(htmlentities(strip_tags($_POST['message'])));
  25. $message = str_replace(array("r", "n"), '', $message);
  26. $message = wordwrap($message, 75, "<br />", true);
  27. $name = str_replace(';', '.-_.-_', $name);
  28. $email = str_replace(';', '.-_.-_', $email);
  29. $homepage = str_replace(';', '.-_.-_', $homepage);
  30. $message = str_replace(';', '.-_.-_', $message);
  31. $writeinfo = "{$date};{$name};{$email};{$homepage};{$message}n";
  32.  
  33. switch($_GET['id'])
  34. {
  35.  
  36. // DEFAULT GUESTBOOK PAGE
  37. default:
  38. echo "<p align="left"><a href="?id=login">Admin</a></p>n";
  39. echo "<table align="center"><form action="?id=write" method="post" name="submitform">n";
  40. echo "<tr><td><strong>Name: *</strong></td><td><input type="text" name="name" size="40" maxlength="50" /></td></tr>n";
  41. echo "<tr><td><strong>Email:</strong></td><td><input type="text" name="email" size="40" maxlength="50" /></td></tr>n";
  42. echo "<tr><td><strong>Homepage:</strong></td><td><input type="text" name="homepage" size="40" maxlength="50" value="http://" /></td></tr>n";
  43. echo "<tr><td valign="top"><strong>Message: *</strong></td><td><textarea name="message" cols="30" rows="7"></textarea></td></tr>n";
  44. echo "<tr><td></td><td><input type="submit" name="submit" value="Submit" /></td></tr>n";
  45. echo "</form></table><br />nn";
  46.  
  47. $gb = file($gbfile);
  48. $gb = array_reverse($gb);
  49. foreach ($gb as $guestbook) {
  50. $gastbok = stripslashes($guestbook);
  51. list($datum, $namn, $epost, $hemsida, $meddelande) = split(';', $gastbok);
  52. $namn = str_replace('.-_.-_',';',$namn);
  53. $epost = str_replace('.-_.-_',';',$epost);
  54. $hemsida = str_replace('.-_.-_',';',$hemsida);
  55. $meddelande = str_replace('.-_.-_',';',$meddelande);
  56. echo "<table width="400" border="1" align="center">n";
  57. echo "<tr><td width="80"><strong>Date:</strong></td><td width="320">{$datum}</td></tr>n";
  58. echo "<tr><td><strong>Name:</strong></td><td>{$namn}</td></tr>n";
  59. echo "<tr><td><strong>Email:</strong></td><td><a href="mailto:{$post}">{$epost}</a></td></tr>n";
  60. echo "<tr><td><strong>Homepage:</strong></td><td><a href="{$hemsida}" target="_blank">{$hemsida}</a></td></tr>n";
  61. echo "<tr><td><strong>Message:</strong></td><td>{$meddelande}</td></tr>n";
  62. echo "</table><br />nn";
  63. }
  64. break;
  65. ...
  66. ?>

Blad to
18, 47, 48, 49 linijka.


Warning: file() [function.file]: Unable to access guestbook.txt in /home/t/r/e/trekker/www/pliki/ksiega/guestbook.php on line 18

Warning: file(guestbook.txt) [function.file]: failed to open stream: No such file or directory in /home/t/r/e/trekker/www/pliki/ksiega/guestbook.php on line 18


Warning: file() [function.file]: Unable to access guestbook.txt in /home/t/r/e/trekker/www/pliki/ksiega/guestbook.php on line 47

Warning: file(guestbook.txt) [function.file]: failed to open stream: No such file or directory in /home/t/r/e/trekker/www/pliki/ksiega/guestbook.php on line 47

Warning: array_reverse() [function.array-reverse]: The argument should be an array in /home/t/r/e/trekker/www/pliki/ksiega/guestbook.php on line 48

Warning: Invalid argument supplied for foreach() in /home/t/r/e/trekker/www/pliki/ksiega/guestbook.php on line 49


--------------------
www.picture-globe.com
Go to the top of the page
+Quote Post
virusT
post
Post #6





Grupa: Zarejestrowani
Postów: 16
Pomógł: 1
Dołączył: 10.05.2007
Skąd: Częstochowa / Kraków

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


A moze by tak:
Kod
$gbfile = "../ksiega/guestbook.txt";


i ewentualnie
Kod
$thisfile = "../ksiega/guestbook.php";


Nie daje glowy, ze to zadziala ale sprobowac mozna.

Ten post edytował virusT 12.05.2007, 23:59:48
Go to the top of the page
+Quote Post
Matiash
post
Post #7





Grupa: Zarejestrowani
Postów: 103
Pomógł: 0
Dołączył: 7.04.2007

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


nie dziala. Ale dzieki za pomoc.
To nie wina skrytpu raczej, bo sciagnalem sobie inna ksiege i z nia jest dokladnie tak samo.
Zmienilem troche sciezki w mojej stronie ale ogolnie schemat drzewa folderow jest podobny.

http://trekker.ovh.org/includes/podstrony/ksiega.php - nie działa


http://trekker.ovh.org/includes/podstrony/...a/guestbook.php - działa

Ten post edytował Matiash 13.05.2007, 00:12:09


--------------------
www.picture-globe.com
Go to the top of the page
+Quote Post
Kicok
post
Post #8





Grupa: Zarejestrowani
Postów: 1 033
Pomógł: 125
Dołączył: 17.09.2005
Skąd: Żywiec

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


Zrozum, że jeśli zaincludowałeś plik guestbook.php do pliku podstrona1.php, to treść tego pierwszego jest jakby przepisana do drugiego pliku. Tak więc nie siedzi on już w katalogu ksiega, tylko w katalogu pliki - i to z tego katalogu powinieneś odwoływać się do pliku guestbook.txt

Co więcej, jeśli ten plik podstrona1.php jest includowany w index.php, to całość przepisana jest do tego drugiego pliku i siedzi w katalogu głównym. W takim przypadku do pliku guestbook.txt odwołujesz się z katalogu www, a nie ksiega

Ten post edytował Kicok 13.05.2007, 06:52:58


--------------------
"Sumienie mam czyste, bo nieużywane."
Go to the top of the page
+Quote Post
Matiash
post
Post #9





Grupa: Zarejestrowani
Postów: 103
Pomógł: 0
Dołączył: 7.04.2007

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


Kicok no i o to mi chodzilo exclamation.gif Dziekuje bardzo za wyjasnienie sprawy !

Pozdrawiam winksmiley.jpg


--------------------
www.picture-globe.com
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 21.08.2025 - 22:39