Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> problem z else, {
maxer
post 19.06.2004, 11:26:08
Post #1





Grupa: Zarejestrowani
Postów: 36
Pomógł: 0
Dołączył: 23.03.2004
Skąd: Poznań

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


Mój kod to (jest to tylko częśc kodu, reszta to zwykły html):
  1.     <?php
  2.       if (!isset ($dzial) ){
  3.       include (&#092;"index.php\")
  4.       } else { 
  5.       if ($dzial == news){ 
  6.       include (&#092;"news/show.php\"); 
  7.       }else if ($dzial == lista){
  8.       include (&#092;"strona/lista.php\");
  9.       }else if ($dzial== zarzad){
  10.       include (&#092;"strona/zarzad.php\");
  11.       }else if ($dzial== kontakt){
  12.       include (&#092;"strona/kontakt.php\");
  13.       }else if ($dzial== my){
  14.       include (&#092;"strona/o_nas.php\");
  15.       }else if ($dzial== spotkania){
  16.       include (&#092;"strona/spotkania.php\");
  17.       }else if ($dzial== typer){
  18.       include (&#092;"strona/typer.php\");
  19.       }else if ($dzial== statsy){
  20.       include (&#092;"strona/statsy.php\");
  21.       }
  22.       ?>  

Po wysłaniu na serwer wyswietla sie następująca wiadomośc:
    Parse error: parse error, unexpected '}' in /home/maxer/public_html/TEST/index.php on line 54
Nie mogę nigdzie znaleźć błędu. Proszę pomóżcie i powiedzcie co tutaj jest żle.
Pozdrawiam

Ten post edytował maxer 19.06.2004, 12:00:53


--------------------
sygnaturka :)
Go to the top of the page
+Quote Post
Chewolf
post 19.06.2004, 11:31:55
Post #2





Grupa: Zarejestrowani
Postów: 335
Pomógł: 0
Dołączył: 15.11.2003

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


Jednego nawisu ci zabrakło biggrin.gif :
zrób:
  1. <?php
  2.  include (&#092;"strona/statsy.php\");
  3.  }
  4.  }
  5.  ?>
Go to the top of the page
+Quote Post
Ludvik
post 19.06.2004, 11:32:40
Post #3





Grupa: Przyjaciele php.pl
Postów: 698
Pomógł: 3
Dołączył: 28.03.2004
Skąd: Wrocław

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


Zgubiłeś średnik przy pierwszym include.
  1. <?php
  2.  if (!isset ($dzial) ){
  3.  include (&#092;"index.php\")// Tutaj powinien być średnik.
  4.  } ...
  5. ?>


PS. Polecam na przyszłość napisać, która to linia w kodzie jest. To znacznie przyspiesza wyszukiwanie błędów...

Ten post edytował Ludvik 19.06.2004, 11:36:06


--------------------
Go to the top of the page
+Quote Post
ceo
post 19.06.2004, 11:56:54
Post #4





Grupa: Zarejestrowani
Postów: 42
Pomógł: 0
Dołączył: --

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


a nie lepiej to zrobic na switchu ?

switch($dzial) {

case"news":include("news/show.php");break;
case"lista":include("strona/lista.php");break;
......
default:include("index.php");break;

}
Go to the top of the page
+Quote Post
Chewolf
post 19.06.2004, 11:59:14
Post #5





Grupa: Zarejestrowani
Postów: 335
Pomógł: 0
Dołączył: 15.11.2003

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


Pewnie że można łatwiej... ale jemu chodzi o pomoc w rozwiazaniu problemu z jego kodem !
Go to the top of the page
+Quote Post
BzikOS
post 19.06.2004, 12:00:04
Post #6





Grupa: Przyjaciele php.pl
Postów: 660
Pomógł: 0
Dołączył: 28.08.2002
Skąd: Starachowice

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


@maxer, @ceo: proszę umieszczać kod php w odpowiednich znacznikach BBCode.
Go to the top of the page
+Quote Post
maxer
post 19.06.2004, 12:03:05
Post #7





Grupa: Zarejestrowani
Postów: 36
Pomógł: 0
Dołączył: 23.03.2004
Skąd: Poznań

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


niestety po zrobieniu tego co mi poradzono w dwóch pierwszych posatch:
    Parse error: parse error, unexpected T_IF, expecting '(' in /home/maxer/public_html/YWNWA/YWNWA/index.php on line 55
sad.gif
Chyba spróbuje ze switch chociaż nie za bradzo wiem o co chodzi :/
Ale chyba sie naucze smile.gif

Ten post edytował maxer 19.06.2004, 12:09:16


--------------------
sygnaturka :)
Go to the top of the page
+Quote Post
Chewolf
post 19.06.2004, 12:08:39
Post #8





Grupa: Zarejestrowani
Postów: 335
Pomógł: 0
Dołączył: 15.11.2003

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


Mi taki kod działa :
  1. <?php
  2.      $dzial = $_GET['dzial'];
  3.      if (!isset ($dzial) ){
  4.      include (&#092;"index.php\");
  5.      } else {
  6.      if ($dzial == news){
  7.      include (&#092;"news/show.php\");
  8.      }else if ($dzial == lista){
  9.      include (&#092;"strona/lista.php\");
  10.      }else if ($dzial== zarzad){
  11.      include (&#092;"strona/zarzad.php\");
  12.      }else if ($dzial== kontakt){
  13.      include (&#092;"strona/kontakt.php\");
  14.      }else if ($dzial== my){
  15.      include (&#092;"strona/o_nas.php\");
  16.      }else if ($dzial== spotkania){
  17.      include (&#092;"strona/spotkania.php\");
  18.      }else if ($dzial== typer){
  19.      include (&#092;"strona/typer.php\");
  20.      }else if ($dzial== statsy){
  21.      include (&#092;"strona/statsy.php\");
  22.      }
  23.      }
  24. ?>

Te krzaki zamień na !:
if (!isset ($dzial) ){

Ten post edytował m5910 19.06.2004, 12:09:31
Go to the top of the page
+Quote Post
Supol
post 19.06.2004, 12:17:02
Post #9





Grupa: Zarejestrowani
Postów: 33
Pomógł: 0
Dołączył: 20.09.2003

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


brakuje Ci } na samym koncu (kod m5910 go juz zawiera)
Go to the top of the page
+Quote Post
maxer
post 19.06.2004, 12:48:14
Post #10





Grupa: Zarejestrowani
Postów: 36
Pomógł: 0
Dołączył: 23.03.2004
Skąd: Poznań

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


Dzięki wielkie m5910 za ten kod
  1. <?php
  2. if(!isset($_GET['dzial'])) {
  3. $dzial=&#092;"index\";
  4. }
  5. if(file_exists(&#092;"include/$dzial.php\")) {
  6. include &#092;"include/$dzial.php\";
  7. } 
  8. else {
  9. echo &#092;"Strona niedostępna!\";
  10. }
  11. ?>

Wszystko działa jak powinno biggrin.gif


--------------------
sygnaturka :)
Go to the top of the page
+Quote Post
Dawid Pytel
post 19.06.2004, 13:14:50
Post #11





Grupa: Zarejestrowani
Postów: 133
Pomógł: 0
Dołączył: 15.09.2003

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


A tak na przyszłość, błędem w Twoim skrypcie było złe użycie stringów:

nie:
  1. <?php
  2.  
  3. ($dzial == news)
  4.  
  5. ?>


tylko

  1. <?php
  2.  
  3. ($dzial == &#092;"news\")
  4.  
  5. ?>


nie umieściłeś ich pomiędzy znakami " " lub ' '.


--------------------
Ez Partner :]
Go to the top of the page
+Quote Post
party
post 19.06.2004, 16:48:24
Post #12





Grupa: Zarejestrowani
Postów: 131
Pomógł: 0
Dołączył: 19.08.2003
Skąd: Bydgoszcz

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


Nie róbcie jaj... zamiast else daj elseif. Jeżeli zmienna $dział jest z adresu (a prawdopodobnie jest) to zamiast $dzial daj $_GET['dzial'].
  1. <?php
  2. if( !isset( $_GET['dzial'] ) )
  3. {
  4.  include( &#092;"index.php\" );
  5. }
  6. elseif( $_GET['dzial'] == 'news' )
  7. {
  8.  include( &#092;"news/show.php\" );
  9. }
  10. elseif( $_GET['dzial'] == 'lista' )
  11. {
  12.  include( &#092;"strona/lista.php\" );
  13. }
  14. elseif( $_GET['dzial'] == 'zarzad' )
  15. {
  16.  include( &#092;"strona/zarzad.php\" );
  17. }
  18. elseif( $_GET['dzial'] == 'kontakt' )
  19. {
  20.  include( &#092;"strona/kontakt.php\" );
  21. }
  22. elseif( $_GET['dzial'] == 'my' )
  23. {
  24.  include( &#092;"strona/o_nas.php\" );
  25. }
  26. elseif( $_GET['dzial'] == 'spotkania' )
  27. {
  28.  include( &#092;"strona/spotkania.php\" );
  29. }
  30. elseif( $_GET['dzial'] == 'typer' )
  31. {
  32.  include( &#092;"strona/typer.php\" );
  33. }
  34. elseif( $_GET['dzial'] == 'statsy' )
  35. {
  36.  include( &#092;"strona/statsy.php\" );
  37. }
  38. ?>


Ten post edytował Partyzant 19.06.2004, 16:51:57


--------------------
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 Wersja Lo-Fi Aktualny czas: 26.04.2024 - 06:12