Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php]Błąd syntax error, unexpected
czona
post
Post #1





Grupa: Zarejestrowani
Postów: 13
Pomógł: 0
Dołączył: 17.05.2007

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


Mój skrypt to:
  1. <DOCTYPE HTML PUBLIC "//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
  5. <title>Motór nie odpalił
  6. </title>
  7. </head>
  8. <body>
  9. <?php
  10. $filesPath = "./";
  11. function checkFileName($name)
  12. {
  13. $plik = array(
  14. "motor.avi"
  15. );
  16. return array_search($name, $plik);
  17. }
  18. function send($fileName, $filePath)
  19. {
  20. if(!file_exists($filePath.$fileName)){
  21. return false;
  22. }
  23. $fd = fopen($filePath.$fileName,"r");
  24. $size = filesize($filePath.fileName);
  25. $contents = fread($fd, filesize($filePath.$fileName));
  26.  
  27. fclose($fd);
  28.  
  29. header("Content-Type: video/x-msvideo");
  30. header("Content-Lenght: $size;");
  31. header("Content-Disposition: attachment; filename=$fileName");
  32.  
  33. echo $contents;
  34. return true;
  35. }
  36.  
  37. if(isSet($_GET['name']) === false){
  38. include "nofile.html";
  39. }
  40. else{
  41. if (!send($_GET['name'], $filesPath)){
  42. include "nofile.html";
  43. }
  44. }
  45. }
  46. else{
  47. include "nofile.html";
  48. }
  49. ?>
  50. </body>
  51. </html>

prosze o pomoc w związku z błędem:
Parse error: syntax error, unexpected '}' in C:\Program Files\Apache Group\Apache2\htdocs\download.php on line 45

Ten post edytował czona 18.05.2007, 17:46:21
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 8)
dr_bonzo
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 5 724
Pomógł: 259
Dołączył: 13.04.2004
Skąd: N/A

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


Stosuj odpowiednie wciecia kodu, to wtedy szybciej znajdziesz blad. Ew. uzyj lepszego IDE do php, ktory ci skladnie pokoloruje i wskaze takie bledy w kodzie.


--------------------
Nie lubię jednorożców.
Go to the top of the page
+Quote Post
czona
post
Post #3





Grupa: Zarejestrowani
Postów: 13
Pomógł: 0
Dołączył: 17.05.2007

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


sad.gif składnie sobie takim fajniutkim programikiem pokolorowałem wcięcia porobiłem ale błędu nie widze jesli ktos go dostrzegł to niech pomoże
sad.gif
Go to the top of the page
+Quote Post
MiFlo
post
Post #4





Grupa: Zarejestrowani
Postów: 92
Pomógł: 4
Dołączył: 12.09.2006
Skąd: 127.0.0.1

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


Usuń z 45 linijki znak"}" bo to o niego chodzi chyba ( tak na szybkiego popatrzyłem tongue.gif
Go to the top of the page
+Quote Post
czona
post
Post #5





Grupa: Zarejestrowani
Postów: 13
Pomógł: 0
Dołączył: 17.05.2007

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


po usunięciu linijki 45 pojawia sie błąd :

Parse error: syntax error, unexpected T_ELSE in C:\Program Files\Apache Group\Apache2\htdocs\download.php on line 45
oczywiście teraz chodzi o linie 46 poniewaz linie 45 usunołem
Go to the top of the page
+Quote Post
MiFlo
post
Post #6





Grupa: Zarejestrowani
Postów: 92
Pomógł: 4
Dołączył: 12.09.2006
Skąd: 127.0.0.1

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


albo mi się zdaje albo ten kawałek
  1. <?php
  2. }
  3. else{
  4. include "nofile.html";
  5. }
  6. ?>

robi błąd usuń go smile.gif
Go to the top of the page
+Quote Post
czona
post
Post #7





Grupa: Zarejestrowani
Postów: 13
Pomógł: 0
Dołączył: 17.05.2007

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


teraz pojawiają się komunikaty:
Parse error: syntax error, unexpected $end in C:\Program Files\Apache Group\Apache2\htdocs\download.php on line 46
Go to the top of the page
+Quote Post
dr_bonzo
post
Post #8





Grupa: Przyjaciele php.pl
Postów: 5 724
Pomógł: 259
Dołączył: 13.04.2004
Skąd: N/A

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


A teraz?
  1. <?php
  2. $filesPath = "./";
  3. function checkFileName($name)
  4. {
  5. $plik = array("motor.avi");
  6. return array_search($name, $plik);
  7. }
  8.  
  9. function send($fileName, $filePath)
  10. {
  11. if(!file_exists($filePath.$fileName)){
  12. return false;
  13. }
  14.  
  15. $fd = fopen($filePath.$fileName,"r");
  16. $size = filesize($filePath.fileName);
  17. $contents = fread($fd, filesize($filePath.$fileName));
  18.  
  19. fclose($fd);
  20.  
  21. header("Content-Type: video/x-msvideo");
  22. header("Content-Lenght: $size;");
  23. header("Content-Disposition: attachment; filename=$fileName");
  24.  
  25. echo $contents;
  26. return true; // a ten return to skad?
  27.  
  28. } // a kuku
  29.  
  30. if(isSet($_GET['name']) === false)
  31. {
  32. include "nofile.html";
  33. }
  34. else
  35. {
  36. if (!send($_GET['name'], $filesPath))
  37. {
  38. include "nofile.html";
  39. }
  40. }
  41. } // i tu tez
  42. else // i tu (2gie else)
  43. {
  44. include "nofile.html";
  45. }
  46. ?>


--------------------
Nie lubię jednorożców.
Go to the top of the page
+Quote Post
czona
post
Post #9





Grupa: Zarejestrowani
Postów: 13
Pomógł: 0
Dołączył: 17.05.2007

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


Parse error: syntax error, unexpected '}' in C:\Program Files\Apache Group\Apache2\htdocs\download.php on line 41
a taeraz tak
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: 19.08.2025 - 07:41