Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [php] Parse error T_STRING
k073l
post 22.08.2016, 18:38:28
Post #1





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 22.08.2016

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


Witam.
Mam problem z kodem.
Przybliżona budowa kodu:
login.php
  1. $ipAddress = $_SERVER['REMOTE_ADDR'];
  2.  
  3. if ($ipAddress == 'mojeip' ) {
  4. //login.php działające
  5. } else {
  6. //open up the log file
  7. $file = fopen(‘log.html’, ‘a’);
  8.  
  9. //write the time of access
  10.  
  11. $time = date(‘H:i dS F’);
  12. fwrite($file, &#8216;<b>Time:</b> $time<br/>’ );
  13.  
  14. //write the users IP address
  15. fwrite( $file, &#8216;<b>Ip Address:</b> $REMOTE_ADDR<br/>’);
  16.  
  17. //write out the page that sent them here
  18. fwrite($file, &#8216;<b>Referer:</b> $HTTP_REFFERER<br/>’);
  19.  
  20. //write the users browser details
  21.  
  22. fwrite( $file, &#8216;<b>Browser:</b> $HTTP_USER_AGENT<hr/>’);
  23.  
  24. //and finial, close the log file
  25. fclose( $file );
  26. //działające login.php
  27. }


Błąd występuje w kodzie po else:
Najpierw nie podobało się ":" ze zmiennej time, potem ">" i "<".
Po usunięciu niewygodnych znaków zwraca błąd jak wcześniej nie podając znaków.

Kod ma sprawdzać IP - jeśli jest moje wykonać co jest po if, jeśli nie dodać log i kontynuować.
Go to the top of the page
+Quote Post
viking
post 22.08.2016, 18:46:21
Post #2





Grupa: Zarejestrowani
Postów: 6 377
Pomógł: 1116
Dołączył: 30.08.2006

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


Pozamieniaj te wszystkie apostrofy ‘ na '


--------------------
Go to the top of the page
+Quote Post
k073l
post 22.08.2016, 18:54:04
Post #3





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 22.08.2016

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


Parse error: syntax error, unexpected T_STRING on line 130

jedyne co zmieniłem to log.html na log.txt

no i te apostrofy

EDIT: Spróbowałem też z log.html pokazuje to samo


Ten post edytował k073l 22.08.2016, 18:57:27
Go to the top of the page
+Quote Post
Pyton_000
post 22.08.2016, 18:58:31
Post #4





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


Już samo podświetlanie składni forum powinno dać Ci do myślenia/
Go to the top of the page
+Quote Post
k073l
post 22.08.2016, 20:57:12
Post #5





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 22.08.2016

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


Racja.
Wcześniej nie działało.
Można zamknąć

Ten post edytował k073l 22.08.2016, 20:57:58
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: 13.06.2025 - 11:30