Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Closed TopicStart new topic
> [PHP]Opis i problem z else:, Parse error: syntax error, unexpected T_ELSE
Adis92
post
Post #1





Grupa: Zarejestrowani
Postów: 146
Pomógł: 12
Dołączył: 9.01.2009
Skąd: Płock

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


Witajcie. Mam skrypt który ma za zadanie dodać opis o mnie. Niby wszystko ładnie tylko mam 1 błąd. A mianowicie:
  1. [b]Parse error:[/b] syntax error, unexpected T_ELSE in [b]/ścieżka do pliku/opis.php[/b] on line [b]34[/b]

a to plik opis.php
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
  2. <HTML>
  3. <HEAD>
  4. <meta http-equiv="Content-type" content="text/html"; charset=windows-1250">
  5. <meta name="author" content="Sunrise">
  6. <link rel="stylesheet" href="style.css" type="text/css">
  7. <title>dodaj opis</title>
  8. </HEAD>
  9.  
  10. <?php
  11. $tresc = $_POST['tresc'];
  12. $obrazek = '<img style="position: absolute; margin: 14px 10px 0px 100px;"src="images/blad.png">';
  13.  
  14. if($tresc) {
  15.  
  16. include("includes/db.inc.php");
  17.  
  18. $connection = mysql_connect($host, $user, $password)
  19. or die("".$obrazek. "<h5>Brak połączenia z serverem MySQL</h5>");
  20. $db = mysql_select_db($baza, $connection)
  21. or die("".$obrazek. "<h5>Brak połączenia z bazą danych</h5>");
  22.  
  23. mysql_query("SET NAMES 'cp1250'");
  24.  
  25. $ins = mysql_query("INSERT INTO opis SET tresc='$tresc'") or die("MySQL ERROR: ".mysql_error());
  26.  
  27. if($ins) echo "<img style='position: absolute; margin: 14px 10px 0px 100px;'src='images/article.png'><h5>Opis dodano poprawnie<h5><br><a href='?ids=o_firmie'><h5>Powrót</h5></a>";
  28.  
  29. else echo "<h5>Błąd! Nie udało dodać się opisu.</h5>";
  30.  
  31. } else echo "".$obrazek."<h5>Uzupełnij wszystkie pola<h5><br><a href='java script:history.back()'><h5>Powrót</h5></a>";
  32.  
  33. ?>
  34. <?php else: ?>
  35.  
  36. <div id="haslo">
  37.  
  38. <img style="position: absolute; margin: -5px 0px 0px -25px;"src="images/pencil.png"><p>O Mnie.</p><br>
  39.  
  40. <div class="box">
  41.  
  42. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" name="firma" accept-charset="utf-8">
  43.  
  44. <input type="submit" name="submit" class="pisz" value="">
  45. <input type="reset" name="reset" class="reset" value="">
  46.  
  47. Opis:<br>
  48. <textarea name="tresc" tabindex="1" title="Opis..." ></textarea><br><br><br><br>
  49.  
  50. </form>
  51.  
  52. </div>
  53. </div>
  54.  
  55. <?php endif; ?>

Ktoś wie co jest grane questionmark.gif
Go to the top of the page
+Quote Post
marian2299
post
Post #2





Grupa: Zarejestrowani
Postów: 272
Pomógł: 9
Dołączył: 6.06.2009

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


  1. <?php else: ?>

Ad 1. "syntax error, unexpected T_ELSE ". Ciekawe dlaczego. Masz Else bez IF.
Ad 2. Zamiast ";" masz ":".


--------------------
film edit student
Go to the top of the page
+Quote Post
Suh
post
Post #3





Grupa: Zarejestrowani
Postów: 112
Pomógł: 27
Dołączył: 24.08.2007
Skąd: Tarnów

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


http://pl.php.net/manual/pl/control-struct...tive-syntax.php


--------------------
Pomogłem ? Odwdzięcz się, kliknij POMÓGŁ.
Go to the top of the page
+Quote Post
webdice
post
Post #4


Developer


Grupa: Moderatorzy
Postów: 3 045
Pomógł: 290
Dołączył: 20.01.2007




Cytat(marian2299 @ 9.08.2009, 02:47:52 ) *
Ad 1. "syntax error, unexpected T_ELSE ". Ciekawe dlaczego. Masz Else bez IF.
Ad 2. Zamiast ";" masz ":".


Gadasz brednie, if jest. Są dwie konstrukcje zapisu instrukcji warunkowych, Ty je mieszasz.
Go to the top of the page
+Quote Post
Pawel_W
post
Post #5





Grupa: Zarejestrowani
Postów: 1 675
Pomógł: 286
Dołączył: 15.06.2009
Skąd: Wieliczka

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


a wcale nie, tam jest:

if
else
else
endif
Go to the top of the page
+Quote Post
marian2299
post
Post #6





Grupa: Zarejestrowani
Postów: 272
Pomógł: 9
Dołączył: 6.06.2009

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


^^ No właśnie smile.gif. webdice, przeczytaj dokładnie.


--------------------
film edit student
Go to the top of the page
+Quote Post
batman
post
Post #7





Grupa: Moderatorzy
Postów: 2 921
Pomógł: 269
Dołączył: 11.08.2005
Skąd: 127.0.0.1




1. Forum to nie parser kodu. Zainstaluj coś, co pokazuje błędy (Eclipse, Netbeans, Komodo, itp).
2. Jak już kopiujesz jakieś skrypty, to rób to z głową. Co tam robi
  1. <?php else: ?>
oraz
  1. <?php endif; ?>
?

Zamykam ze względu na pkt 1.


--------------------
I would love to change the world, but they won't give me the source code.
My software never has bugs. It just develops random features.
Go to the top of the page
+Quote Post

Closed 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 - 14:24