Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Closed TopicStart new topic
> [MySQL][PHP]Błąd w kodzie
Roowinek
post 11.07.2013, 18:35:14
Post #1





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

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


Witam, mam błąd w pliku index.php w lini 57. Mógłby mi ktoś to naprawić? (komentarzy nie mam w kodzie, oznaczyłem tylko linie smile.gif


switch($_GET['u']) //55 linia

case 'sila': //57 linia

if ($user['um'] > 0){ //59 linia itd..

$ap = floor(($user['sila']) * 1.2);

mysql_query("UPDATE gracze SET sila = sila + 1, um = um - 1, ap = ap + ".$ap." WHERE id = ".$user['id']);

header("Location: index.php?a=stats");

} else {

header("Location: index.php?a=stats");

}

break;
Go to the top of the page
+Quote Post
com
post 11.07.2013, 18:44:44
Post #2





Grupa: Zarejestrowani
Postów: 3 034
Pomógł: 366
Dołączył: 24.05.2012

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


korzystaj z znaczników do kodu, brakuje { }
  1. switch($_GET['u']) //55 linia
  2. {
  3. case 'sila': //57 linia
  4.  
  5. if ($user['um'] > 0){ //59 linia itd..
  6.  
  7. $ap = floor(($user['sila']) * 1.2);
  8.  
  9. mysql_query("UPDATE gracze SET sila = sila + 1, um = um - 1, ap = ap + ".$ap." WHERE id = ".$user['id']);
  10.  
  11. header("Location: index.php?a=stats");
  12.  
  13. } else {
  14.  
  15. header("Location: index.php?a=stats");
  16.  
  17. }
  18.  
  19. break;
  20. }
Go to the top of the page
+Quote Post
sajegib
post 11.07.2013, 18:46:34
Post #3





Grupa: Zarejestrowani
Postów: 352
Pomógł: 59
Dołączył: 16.01.2013

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


http://php.net/manual/en/control-structures.switch.php

Poczytaj o składni switch
Go to the top of the page
+Quote Post
Roowinek
post 11.07.2013, 18:48:57
Post #4





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

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


Teraz dodałem wszędzie znaczniki {} ale mam ten sam błąd w 75 mimo że {} dodałem..

case 'zrecznosc': //75
{
if ($user['um'] > 0){

mysql_query("UPDATE gracze SET zrecznosc = zrecznosc + 1, um = um - 1 WHERE id = ".$user['id']);

header("Location: index.php?a=stats");

} else {

header("Location: index.php?a=stats");

}

break;
}
Go to the top of the page
+Quote Post
sajegib
post 11.07.2013, 18:50:25
Post #5





Grupa: Zarejestrowani
Postów: 352
Pomógł: 59
Dołączył: 16.01.2013

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


a może byś tak wstawił treść błędu?
Go to the top of the page
+Quote Post
com
post 11.07.2013, 18:51:32
Post #6





Grupa: Zarejestrowani
Postów: 3 034
Pomógł: 366
Dołączył: 24.05.2012

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


dałem Ci przecież specjalnie przykład, przy switch brakowało klamerek a nie wszędzie smile.gif po case nie dajesz wink.gif jednak switch a w nim jeszcze if to dość dziwne rozwiązanie wink.gif
Go to the top of the page
+Quote Post
Roowinek
post 11.07.2013, 18:51:53
Post #7





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

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


ten sam : Parse error: syntax error, unexpected 'case' (T_CASE) in C:\wamp\www\EMCE\index.php on line 75
Go to the top of the page
+Quote Post
sajegib
post 11.07.2013, 18:52:41
Post #8





Grupa: Zarejestrowani
Postów: 352
Pomógł: 59
Dołączył: 16.01.2013

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


Wystarczy, że go przeczytasz, albo wkleisz ten błąd (bez ścieżki do pliku) w google i rozwiązanie znajdzie się samo smile.gif
Go to the top of the page
+Quote Post
com
post 11.07.2013, 18:57:35
Post #9





Grupa: Zarejestrowani
Postów: 3 034
Pomógł: 366
Dołączył: 24.05.2012

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


dalej nie działa?

http://ideone.com/jq7AEf

Ten post edytował com 11.07.2013, 19:00:25
Go to the top of the page
+Quote Post
Roowinek
post 11.07.2013, 19:25:16
Post #10





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

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


Działa, ale mam kolejny błąd - linia 55 : Notice: Undefined index: u in C:\wamp\www\EMCE\index.php on line 55



switch($_GET['u']) //55 linia
{
case 'sila': //57 linia

if ($user['um'] > 0){ //59 linia itd..

$ap = floor(($user['sila']) * 1.2);

mysql_query("UPDATE gracze SET sila = sila + 1, um = um - 1, ap = ap + ".$ap." WHERE id = ".$user['id']);

header("Location: index.php?a=stats");

} else {

header("Location: index.php?a=stats");

}

break;
Go to the top of the page
+Quote Post
com
post 11.07.2013, 19:37:30
Post #11





Grupa: Zarejestrowani
Postów: 3 034
Pomógł: 366
Dołączył: 24.05.2012

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


php informuje Cie że zmienna nie istnieje brakuje warunku if(isset($_GET['u']))

btw to nie jest błąd tylko informacja

http://ideone.com/jr5eaO

dalej nie używasz znaczników php...

Ten post edytował com 11.07.2013, 19:43:54
Go to the top of the page
+Quote Post
Roowinek
post 11.07.2013, 19:47:42
Post #12





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

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


Tamto już działa, dzięki.. kolejny błąd... sad.gif

Notice: Undefined index: a in C:\wamp\www\EMCE\index.php on line 27


switch($_GET['a']){ //27

case 'login': require_once('login.php'); break;

case 'register': require_once('register.php'); break;

case 'stats': require_once('stats.php'); break;

case 'config': require_once('config.php'); break;

case 'med': require_once('med.php'); break;

case 'logout':

$_SESSION = array();

session_destroy();

header('Location: index.php');

break;

default: require_once('home.php');

}
Go to the top of the page
+Quote Post
Spawnm
post 11.07.2013, 19:48:57
Post #13





Grupa: Moderatorzy
Postów: 4 069
Pomógł: 497
Dołączył: 11.05.2007
Skąd: Warszawa




Forum nie parser. Naucz się podstaw i pomyśl chwilę zanim zadasz kolejne pytanie.
Zamykam.
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 Wersja Lo-Fi Aktualny czas: 25.07.2025 - 10:08