php hulp gevraagd
mysql_query('UPDATE '.KEY_USERS_TABLE.' Set key_usr_spezial_money=\''.$smuser['key_usr_spezial_money'].'\' where key_usr_id=\''.$smuser['key_usr_id'].'\'')OR die(mysql_error());
op lijn 64 werkt het maar op lijn 123 doet hij het niet
wat is er fout ???
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
header ("Content-Type: text/html; charset=utf-8");
session_start();
include("../inc/global_include.php");
include("inc/game_constants.php");
include("inc/config/material.php"); // Vor game_functions.php (Weil Variablen in einer Funktion gebraucht werden)
include("inc/game_functions.php");
include("inc/config/building.php"); // Wird f�r Bau Update ben�tigt (Rohstoff Geb�ude)
include("inc/config/research.php");
include("inc/config/military.php"); // Wird f�r Bau Update
include("inc/config/ship.php"); // Wird f�r Bau Update ben�tigt
include "inc/lang/". $_SESSION['GAME_LANG'] ."/main.php";
include "inc/lang/". $_SESSION['GAME_LANG'] ."/gold.php";
include("inc/config/travel.php");
$sqlx ='SELECT key_usr_id,key_usr_spezial_money FROM '.KEY_USERS_TABLE.' where key_usr_id=\''.$_SESSION['key_usr_id'].'\'';
$resultx = mysql_query($sqlx) OR die(mysql_error());
$smuser= mysql_fetch_assoc($resultx);
if($_GET['anzahl']<0){$_GET['anzahl']=1;}
if($_GET['rohstoff']<=0){$_GET['rohstoff']=1;}
if($smuser['key_usr_spezial_money']<1) // Zuwenig SpezialMoney
{
echo' '.gold_149.' ';
exit;
}
$sqlug ='SELECT usr_id,usr_gold FROM '.USERS_TABLE.' where usr_id=\''.$_SESSION['usr_id'].'\'';
$resultug = mysql_query($sqlug) OR die(mysql_error());
$usr_gold= mysql_fetch_assoc($resultug);
if($usr_gold['usr_gold'] < time())
{
echo' '.gold_151.' ';
exit;
}
if($_GET['rohstoff']==1){$rohstoffname=index_85;}elseif($_GET['rohstoff']==2){$rohstoffname=index_78;}elseif($_GET['rohstoff']==3){$rohstoffname=index_79;}elseif($_GET['rohstoff']==4){$rohstoffname=index_168;}
if($_GET['rohstoff']==4)
{
$smuser['key_usr_spezial_money']-=$_GET['anzahl'];
if($smuser['key_usr_spezial_money']>=0)
{
$rohstoffanzahl=$ROHSTOFFKURS[$_GET['rohstoff']]*$_GET['anzahl'];
$_SESSION['usr_know']+=$rohstoffanzahl;
mysql_query('UPDATE '.KEY_USERS_TABLE.' Set key_usr_spezial_money=\''.$smuser['key_usr_spezial_money'].'\' where key_usr_id=\''.$smuser['key_usr_id'].'\'')OR die(mysql_error());
mysql_query("UPDATE ". USERS_TABLE ." SET usr_know = usr_know + ". $_SESSION['usr_know'] ." WHERE usr_id = ". $_SESSION['usr_id'] ."");
echo "".$_SESSION['usr_know']." ".$rohstoffname."";
}
else
{
echo' '.gold_149.' ';
exit;
}
}
elseif($_GET['rohstoff']<=3)
{
$rohstoffanzahl=$ROHSTOFFKURS[$_GET['rohstoff']]*$_GET['anzahl'];
$userrohstoffanzahlneu=$_SESSION['settle_mat'][$_GET['rohstoff']]+$rohstoffanzahl;
if($userrohstoffanzahlneu>$_SESSION['settle_save'])
{
$maxuserspeicher=$_SESSION['settle_save']-$_SESSION['settle_mat'][$_GET['rohstoff']];
if($maxuserspeicher>0)
{
$_GET['anzahl']=$maxuserspeicher/$ROHSTOFFKURS[$_GET['rohstoff']]; //SP anzahl
$_GET['anzahl']=round($_GET['anzahl'],2);
$rohstoffanzahl=$ROHSTOFFKURS[$_GET['rohstoff']]*$_GET['anzahl']; // Rohstoff anzahl
$userrohstoffanzahlneu=$_SESSION['settle_mat'][$_GET['rohstoff']]+$rohstoffanzahl;
}
else
{
echo' '.gold_150.' ';
exit;
}
}
$smuser['key_usr_spezial_money']-=$_GET['anzahl'];
$_SESSION['settle_mat'][$_GET['rohstoff']]+=$rohstoffanzahl;
mysql_query('UPDATE '.KEY_USERS_TABLE.' Set key_usr_spezial_money=\''.$smuser['key_usr_spezial_money'].'\' where key_usr_id=\''.$smuser['key_usr_id'].'\'')OR die(mysql_error());
mysql_query("UPDATE ". SETTLE_TABLE ." Set settle_mat".$_GET['rohstoff']."=".$_SESSION['settle_mat'][$_GET['rohstoff']]." WHERE settle_id = ". $_SESSION['this_settle']);
echo"".$_SESSION['settle_mat'][$_GET['rohstoff']]." ".$rohstoffname." ";
}
else
{
echo 'ERROR';
}
?>
header ("Content-Type: text/html; charset=utf-8");
session_start();
include("../inc/global_include.php");
include("inc/game_constants.php");
include("inc/config/material.php"); // Vor game_functions.php (Weil Variablen in einer Funktion gebraucht werden)
include("inc/game_functions.php");
include("inc/config/building.php"); // Wird f�r Bau Update ben�tigt (Rohstoff Geb�ude)
include("inc/config/research.php");
include("inc/config/military.php"); // Wird f�r Bau Update
include("inc/config/ship.php"); // Wird f�r Bau Update ben�tigt
include "inc/lang/". $_SESSION['GAME_LANG'] ."/main.php";
include "inc/lang/". $_SESSION['GAME_LANG'] ."/gold.php";
include("inc/config/travel.php");
$sqlx ='SELECT key_usr_id,key_usr_spezial_money FROM '.KEY_USERS_TABLE.' where key_usr_id=\''.$_SESSION['key_usr_id'].'\'';
$resultx = mysql_query($sqlx) OR die(mysql_error());
$smuser= mysql_fetch_assoc($resultx);
if($_GET['anzahl']<0){$_GET['anzahl']=1;}
if($_GET['rohstoff']<=0){$_GET['rohstoff']=1;}
if($smuser['key_usr_spezial_money']<1) // Zuwenig SpezialMoney
{
echo' '.gold_149.' ';
exit;
}
$sqlug ='SELECT usr_id,usr_gold FROM '.USERS_TABLE.' where usr_id=\''.$_SESSION['usr_id'].'\'';
$resultug = mysql_query($sqlug) OR die(mysql_error());
$usr_gold= mysql_fetch_assoc($resultug);
if($usr_gold['usr_gold'] < time())
{
echo' '.gold_151.' ';
exit;
}
if($_GET['rohstoff']==1){$rohstoffname=index_85;}elseif($_GET['rohstoff']==2){$rohstoffname=index_78;}elseif($_GET['rohstoff']==3){$rohstoffname=index_79;}elseif($_GET['rohstoff']==4){$rohstoffname=index_168;}
if($_GET['rohstoff']==4)
{
$smuser['key_usr_spezial_money']-=$_GET['anzahl'];
if($smuser['key_usr_spezial_money']>=0)
{
$rohstoffanzahl=$ROHSTOFFKURS[$_GET['rohstoff']]*$_GET['anzahl'];
$_SESSION['usr_know']+=$rohstoffanzahl;
mysql_query('UPDATE '.KEY_USERS_TABLE.' Set key_usr_spezial_money=\''.$smuser['key_usr_spezial_money'].'\' where key_usr_id=\''.$smuser['key_usr_id'].'\'')OR die(mysql_error());
mysql_query("UPDATE ". USERS_TABLE ." SET usr_know = usr_know + ". $_SESSION['usr_know'] ." WHERE usr_id = ". $_SESSION['usr_id'] ."");
echo "".$_SESSION['usr_know']." ".$rohstoffname."";
}
else
{
echo' '.gold_149.' ';
exit;
}
}
elseif($_GET['rohstoff']<=3)
{
$rohstoffanzahl=$ROHSTOFFKURS[$_GET['rohstoff']]*$_GET['anzahl'];
$userrohstoffanzahlneu=$_SESSION['settle_mat'][$_GET['rohstoff']]+$rohstoffanzahl;
if($userrohstoffanzahlneu>$_SESSION['settle_save'])
{
$maxuserspeicher=$_SESSION['settle_save']-$_SESSION['settle_mat'][$_GET['rohstoff']];
if($maxuserspeicher>0)
{
$_GET['anzahl']=$maxuserspeicher/$ROHSTOFFKURS[$_GET['rohstoff']]; //SP anzahl
$_GET['anzahl']=round($_GET['anzahl'],2);
$rohstoffanzahl=$ROHSTOFFKURS[$_GET['rohstoff']]*$_GET['anzahl']; // Rohstoff anzahl
$userrohstoffanzahlneu=$_SESSION['settle_mat'][$_GET['rohstoff']]+$rohstoffanzahl;
}
else
{
echo' '.gold_150.' ';
exit;
}
}
$smuser['key_usr_spezial_money']-=$_GET['anzahl'];
$_SESSION['settle_mat'][$_GET['rohstoff']]+=$rohstoffanzahl;
mysql_query('UPDATE '.KEY_USERS_TABLE.' Set key_usr_spezial_money=\''.$smuser['key_usr_spezial_money'].'\' where key_usr_id=\''.$smuser['key_usr_id'].'\'')OR die(mysql_error());
mysql_query("UPDATE ". SETTLE_TABLE ." Set settle_mat".$_GET['rohstoff']."=".$_SESSION['settle_mat'][$_GET['rohstoff']]." WHERE settle_id = ". $_SESSION['this_settle']);
echo"".$_SESSION['settle_mat'][$_GET['rohstoff']]." ".$rohstoffname." ";
}
else
{
echo 'ERROR';
}
?>
Laat je code eens inspringen, dan wordt het leesbaarder en wat voor errors krijg je?
op lijn 123 zou het gewoon het aantal (credits) key_usr_spezial_money moeten wegnemen van die user
Bouw foutafhandeling in dan zie je wat er fout gaat.
Waarschijnlijk bestaat 1 (of misschien beide) variabele niet in 2e instantie. Je kan beter een controle inbouwen (isset/ !empty) of de gebruikte variabelen in de query wel bestaan, als dat niet het geval is kan het natuurlijk ook nooit goed gaan.
JAWOHL USERROHSTOFFANZAHLNEUUBERCOMMANDANTSTORMBAHNFURHER!