Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [php]Błąd syntax error, unexpected
Forum PHP.pl > Forum > Przedszkole
czona
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
dr_bonzo
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.
czona
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
MiFlo
Usuń z 45 linijki znak"}" bo to o niego chodzi chyba ( tak na szybkiego popatrzyłem tongue.gif
czona
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
MiFlo
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
czona
teraz pojawiają się komunikaty:
Parse error: syntax error, unexpected $end in C:\Program Files\Apache Group\Apache2\htdocs\download.php on line 46
dr_bonzo
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. ?>
czona
Parse error: syntax error, unexpected '}' in C:\Program Files\Apache Group\Apache2\htdocs\download.php on line 41
a taeraz tak
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.