Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] problem z podstronami
Jerzy
post
Post #1





Grupa: Zarejestrowani
Postów: 29
Pomógł: 0
Dołączył: 19.08.2007

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


Witam, otóż stworzyłem podstrony w php. Niestety na stronie pojawiają mi się błędy:

index.php
  1. <div id="content_main">
  2. <table boreder="0" cellpadding="0" cellspacing="0">
  3. <tr>
  4. <td>
  5. <?php
  6.  
  7. if ($index=="") {
  8. include("start.php");
  9. }
  10. else {
  11. include("start.php".$start.".php"); 
  12. }
  13.  
  14. include("podstrony/link1.php".$link1.".php");
  15.  
  16. include("podstrony/www.php".$www.".php");
  17.  
  18. include("podstrony/wwww.php".$wwww.".php");
  19.  
  20. ?>
  21. </td>
  22. </tr>
  23. </table>
  24. </div>



Natomiast na Stronie głównej pojawiają się następujące problemy:
  1. <?php
  2. dsadfff
  3. Warning: include(podstrony/link1.php.php) [function.include]: failed to open stream: No such file or directory in E:Program FilesVertrigoServwwwmm_phpindex.php on line 71
  4. Warning: include() [function.include]: Failed opening 'podstrony/link1.php.php' for inclusion (include_path='.;C:php5pear') in E:Program FilesVertrigoServwwwmm_phpindex.php on line 71
  5. Warning: include(podstrony/www.php.php) [function.include]: failed to open stream: No such file or directory in E:Program FilesVertrigoServwwwmm_phpindex.php on line 72
  6. Warning: include() [function.include]: Failed opening 'podstrony/www.php.php' for inclusion (include_path='.;C:php5pear') in E:Program FilesVertrigoServwwwmm_phpindex.php on line 72
  7. Warning: include(podstrony/wwww.php.php) [function.include]: failed to open stream: No such file or directory in E:Program FilesVertrigoServwwwmm_phpindex.php on line 73
  8. Warning: include() [function.include]: Failed opening 'podstrony/wwww.php.php' for inclusion (include_path='.;C:php5pear') in E:Program FilesVertrigoServwwwmm_phpindex.php on line 73
  9. ?>
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 9)
kossa
post
Post #2





Grupa: Zarejestrowani
Postów: 1 165
Pomógł: 9
Dołączył: 9.04.2002
Skąd: Toruń

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


Masz przecież wyraźnie napisane co jest źle.

Zobacz jaki chcesz otwierać plik, np.: podstrony/link1.php.php

Raczej nie masz takiego, a masz taki: podstrony/link1.php

Łukasz


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





Grupa: Zarejestrowani
Postów: 29
Pomógł: 0
Dołączył: 19.08.2007

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


W tym własnie rzecz, iż stwqorzyłem plik np: link1.php  nie wiem dlaczego mi czyta  link1.php.php.
Plik tworzyłem w PSPad editor jak i próbowałem również w notatniku, lecz wciąż to samo.
Go to the top of the page
+Quote Post
kossa
post
Post #4





Grupa: Zarejestrowani
Postów: 1 165
Pomógł: 9
Dołączył: 9.04.2002
Skąd: Toruń

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


Przecież tu masz źle:

Cytat
include("podstrony/link1.php".$link1.".php");


Łukasz


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





Grupa: Zarejestrowani
Postów: 29
Pomógł: 0
Dołączył: 19.08.2007

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


zmieniłem na:
  1. <?php
  2.  
  3. if ($index=="") {
  4. include("start.php");
  5. }
  6. else {
  7. include("start.php".$start.".php"); 
  8. }
  9.  
  10. include("podstrony/link1".$link1.".php");
  11. include("podstrony/link2".$link2.".php");
  12. include("podstrony/link3".$link3.".php");
  13.  
  14. ?>


I działa, nie wywala żadnych błedów, lecz na stronie pojawiają się wszystkie podstrony...
Czyli:

Strona glwona tresc_link1 tresc_link2 tresc_link3

Ten post edytował Jerzy 7.12.2007, 09:03:50
Go to the top of the page
+Quote Post
kossa
post
Post #6





Grupa: Zarejestrowani
Postów: 1 165
Pomógł: 9
Dołączył: 9.04.2002
Skąd: Toruń

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


Skoro masz poza instrukcją if pozostałe strony to muszą się wyświetlić.

Twoja instrukcja if jest bez sensu, obojętnie jaki warunek będzie, zawsze będzie wyświetlona start.php, to po co w ogóle if? smile.gif

Tak się zastanawiam jeszcze po co Tobie zmienne $link1, $link2, $link3 w instrukcji include, skoro jak widać na błędzie w pierwszym poście te zmienne są puste.


Łukasz


--------------------
Go to the top of the page
+Quote Post
Jerzy
post
Post #7





Grupa: Zarejestrowani
Postów: 29
Pomógł: 0
Dołączył: 19.08.2007

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


Więc zmieniłem kod w następujący sposób:

  1. <?php
  2.  
  3. if ($index=="") {
  4. include("start.php");
  5. }
  6. else {
  7. include("start.php.php");
  8. include("podstrony/link1.php");
  9. include("podstrony/link2.php");
  10. include("podstrony/link3.php");
  11. }
  12.  
  13. ?>


No i odwołanie do pliku link1, wygląda tak:

  1. <?php
  2. <a href="index.php?link1=podstrony/link1.php">Link1</a>
  3. ?>


Lecz gdy chce wejsc na podstrone, strona pozostaje bez zmian...

Niestety raczkuję w php i efekty widać.

Ten post edytował Jerzy 7.12.2007, 09:20:44
Go to the top of the page
+Quote Post
kossa
post
Post #8





Grupa: Zarejestrowani
Postów: 1 165
Pomógł: 9
Dołączył: 9.04.2002
Skąd: Toruń

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


Zrób linki tak:

<a href="index.php?link=link1">Link1</a>
<a href="index.php?link=link2">Link2</a>


  1. <?php
  2. if ($_GET["link"]=="link1")
  3.  include("podstrony/link1.php");
  4. else if ($_GET["link"]=="link2")
  5.  include("podstrony/link2.php");
  6. else
  7.  include("start.php");
  8. ?>



edit:
Rozbuduj to o kolejne linki
To tylko przykład
Nie rób w linkach np. link1.php np. haker wie od razu jaki plik includujesz i może go podmienić

To tak na szybko, powodzenia smile.gif

Łukasz

Ten post edytował kossa 7.12.2007, 09:40:32


--------------------
Go to the top of the page
+Quote Post
Jerzy
post
Post #9





Grupa: Zarejestrowani
Postów: 29
Pomógł: 0
Dołączył: 19.08.2007

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


Serdecznie dziękuję za pomoc winksmiley.jpg
Nareszcie uporałem się z tym, mam jeszcze takie pytanie nie związane z tematem.
Wiesz jak zrobić mod rewrite, by wcale nie pojawiały się linki gdy wejdę na jakąs podstronę (np: jest www.mojastrona.pl/index... a chcę by było wciąz samo www.mojastrona.pl)? fajnie było by gdybyś odpowiedział na PW, bo nie chcę robić tu OT.

Jeszcze raz dziękuję biggrin.gif
Go to the top of the page
+Quote Post
kossa
post
Post #10





Grupa: Zarejestrowani
Postów: 1 165
Pomógł: 9
Dołączył: 9.04.2002
Skąd: Toruń

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


Jeśli miało by być tak jak chcesz, czyli zawsze widoczny tylko adres domeny to nazywa się to maskowaniem.

mod_rewrite - masa przykładów na forum - poszukaj

a Twój adres mógłby wyglądać tak: www.mojastrona.pl/link1.html a w .htaccess ustawisz sobie że link1 to wartość zmiennej link


Łukasz


--------------------
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: 22.08.2025 - 04:24