Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Closed TopicStart new topic
> Parse error przy skrypcie... Pomocy ;/
Artheso
post
Post #1





Grupa: Zarejestrowani
Postów: 34
Pomógł: 0
Dołączył: 26.03.2010

Ostrzeżenie: (20%)
X----


Witam, mam taki skrypt:

  1. <?php
  2.  
  3.  
  4. if (isset($_SESSION['user_id']) and isset($_SESSION['login']))
  5.  
  6. {
  7.  
  8. /**
  9.  * Plik generujacy mape na podstawie wczesniej przygotowanej tablicy.
  10.  */
  11.  
  12. // Zalaczanie pliku z polaczeniam do bazy
  13. include('conn.php');
  14.  
  15. // Zalaczane tablicy
  16. include('genmapfile.php');
  17. $login = $_SESSION['login'];
  18.  
  19. /**
  20.  * Pobiera wspolrzedne gracza o ID podanym jako parametr
  21.  *
  22.  * @author: Meares (http://mearesligitharr.blogspot.com/)
  23.  * @name: GetYXForPlayer
  24.  * @param: integer $login
  25.  * @return: array
  26.  */
  27. function GetYXForPlayer($login) {
  28. $Query = mysql_query('SELECT y, x FROM user WHERE login='$login'') or die(mysql_error());
  29. $Fetched = mysql_fetch_assoc($Query);
  30. return $Fetched;
  31. }
  32.  
  33. // Zdobycie wspolrzednych gracza
  34. $YX = GetYXForPlayer(1);
  35.  
  36. if(isset($_GET['y']) || isset($_GET['x'])) {
  37. // Zmiana miejsca gracza
  38. if(($YX['y'] + 1 == $_GET['y'] || $YX['y'] - 1 == $_GET['y'] || $YX['y'] == $_GET['y']) && ($YX['x'] + 1 == $_GET['x'] || $YX['x'] - 1 == $_GET['x'] || $YX['x'] == $_GET['x']) && $Map[$_GET['y']][$_GET['x']]['CanBeOn'] === true) {
  39. mysql_query('UPDATE `user` SET `y`='.$_GET['y'].', `x`='.$_GET['x'].' WHERE `login`='$login'');
  40. } else {
  41. echo 'Cheater!';
  42. }
  43. }
  44.  
  45. // Zdobycie aktualnych wspolrzednych gracza
  46. $YX = GetYXForPlayer(1);
  47.  
  48. // Generowanie
  49. // $Key zawiera wspolrzedna Y
  50. foreach($Map as $Key => $Value) {
  51. // $Key2 zawiera wspolrzedna X, a $Value2 to tablica zawierajaca informacje o podlozu oraz o tym czy na dane pole mozna wejsc
  52. foreach($Value as $Key2 => $Value2) {
  53. $EchoString[0] = '<span style="position: relative; left: 1px; z-index: 1;"><img src="images/'.$Value2['Image'].'" alt="MapElement" style="width: 32px; height: 32px;" /></span>';
  54. // Jesli mozna wejsc na pole
  55. if($Value2['CanBeOn'] === true) {
  56. // Generowanie "strzaleczek"
  57. if($Key - 1 == $YX['y'] && $Key2 == $YX['x']) {
  58. $EchoString[1] = '<span style="position: relative; left: 0px; z-index: 2;"><a href="index.php?y='.$Key.'&x='.$Key2.'"><img src="images/arrow_down.png" alt="Go!" style="position: absolute; right: 0px; width: 32px; height: 32px;border: 0; " /></a></span>';
  59. } else if($Key + 1 == $YX['y'] && $Key2 == $YX['x']) {
  60. $EchoString[1] = '<span style="position: relative; left: 0px; z-index: 2;"><a href="index.php?y='.$Key.'&x='.$Key2.'"><img src="images/arrow_up.png" alt="Go!" style="position: absolute; right: 0px; width: 32px; height: 32px; border: 0; " /></a></span>';
  61. } else if($Key2 - 1 == $YX['x'] && $Key == $YX['y']) {
  62. $EchoString[1] = '<span style="position: relative; left: 0px; z-index: 2;"><a href="index.php?y='.$Key.'&x='.$Key2.'"><img src="images/arrow_right.png" alt="Go!" style="position: absolute; right: 0px; width: 32px; height: 32px; border: 0; " /></a></span>';
  63. } else if($Key2 + 1 == $YX['x'] && $Key == $YX['y']) {
  64. $EchoString[1] = '<span style="position: relative; left: 0px; z-index: 2;"><a href="index.php?y='.$Key.'&x='.$Key2.'"><img src="images/arrow_left.png" alt="Go!" style="position: absolute; right: 0px; width: 32px; height: 32px; border: 0; " /></a></span>';
  65. } else if($Key == $YX['y'] && $Key2 == $YX['x']) {
  66. $EchoString[1] = '<span style="position: relative; left: 0px; z-index: 2;"><img src="images/character.png" alt="Character" style="position: absolute; right: 0px; width: 32px; height: 32px;" /></span>';
  67. } else {
  68. $EchoString[1] = '';
  69. }
  70. } else {
  71. $EchoString[1] = '';
  72. }
  73. echo implode('', $EchoString);
  74. }
  75. echo '<br />';
  76. }
  77.  
  78. }
  79.  
  80. else
  81.  
  82. {
  83.  
  84. echo "Nie jestes zalogowany";
  85.  
  86.  
  87.  
  88. }


I nie działa on poprawnie. Wyskakuje:

Parse error: syntax error, unexpected T_VARIABLE in /home/sites/e/en/end/endoria.za.pl/test/index.php on line 29

Czyli, że błąd jest w tej linijce:

  1. $Query = mysql_query('SELECT y, x FROM user WHERE login='$login'') or die(mysql_error());


Próbowałem dodawać apostrofy, itd ale to i tak nie działa... Mógłby mi ktoś pomóc? Byłbym wdzięczny winksmiley.jpg)))
Go to the top of the page
+Quote Post
jareeny
post
Post #2





Grupa: Zarejestrowani
Postów: 226
Pomógł: 23
Dołączył: 2.10.2007
Skąd: Słupsk

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


  1. $Query = mysql_query("SELECT y, x FROM user WHERE login='$login'") or die(mysql_error());


tak spróbuj.


--------------------
banan wszyscy.
Go to the top of the page
+Quote Post
Artheso
post
Post #3





Grupa: Zarejestrowani
Postów: 34
Pomógł: 0
Dołączył: 26.03.2010

Ostrzeżenie: (20%)
X----


Po zmianie wyskakuje taki błąd:

Parse error: syntax error, unexpected T_VARIABLE in /home/sites/e/en/end/endoria.za.pl/test/index.php on line 41


Linijka 41:
  1. mysql_query('UPDATE `user` SET `y`='.$_GET['y'].', `x`='.$_GET['x'].' WHERE `login`='$login'');


Wydaje mi się, że należy jeszcze to poprawić, i będzie śmigać... Ale niestety nie wiem, jak to poprawić, bo tutaj jest dużo tych różnych znaczków.
Go to the top of the page
+Quote Post
gigzorr
post
Post #4





Grupa: Zarejestrowani
Postów: 652
Pomógł: 47
Dołączył: 6.02.2010
Skąd: Radom

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


Cytat(Artheso @ 18.04.2010, 09:18:27 ) *
Po zmianie wyskakuje taki błąd:

Parse error: syntax error, unexpected T_VARIABLE in /home/sites/e/en/end/endoria.za.pl/test/index.php on line 41


Linijka 41:
  1. mysql_query('UPDATE `user` SET `y`='.$_GET['y'].', `x`='.$_GET['x'].' WHERE `login`='$login'');


Wydaje mi się, że należy jeszcze to poprawić, i będzie śmigać... Ale niestety nie wiem, jak to poprawić, bo tutaj jest dużo tych różnych znaczków.

Spróbuj tak:

  1. mysql_query("UPDATE `user` SET `y`='.$_GET['y'].', `x`='.$_GET['x'].' WHERE `login`='$login''');
Go to the top of the page
+Quote Post
batman
post
Post #5





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




Pytasz o podstawy podstaw. Zainstaluj dowolny edytor, który pokazuje błędy i od razu będziesz wiedział gdzie jest błąd.
Zamykam.


--------------------
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: 20.08.2025 - 04:49