SQL Update probleem

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Dennis

Dennis

24/08/2008 22:25:00
Quote Anchor link
Hallo allemaal,

Mijn probleem zit hem in het volgende. Op mijn site/spel, kan men een casino kopen of andere properties met punten. Nu werkt het zoverre dat de punten van de koper er af gaan en bij de verkoper erbij komen, echter...het casino wordt niet op naam gezet van de koper.

Ben het nu al een paar keer door gegaan echter ik zie het niet, wellicht dat jullie mij verder op weg kunnen helpen.

Alvast bedankt!

Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
<?
// Casino being bought

if(isset($_POST['Purchase3'])){

$sql = "SELECT name,credits FROM login WHERE id='" .mysql_real_escape_string($_SESSION['user_id']). "' ";
$query = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_object($query);
$credits = htmlspecialchars($row->credits);
$buyer_name = htmlspecialchars($row->name);

$sql = "SELECT * FROM casino_sell WHERE id='".mysql_real_escape_string($_POST['name3'])."' ";
$query = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_object($query);
$price = htmlspecialchars($row->price);
$owner = htmlspecialchars($row->owner);
$type = htmlspecialchars($row->type);
$location = htmlspecialchars($row->location);

if($credits < $price){
echo "<font color='#ffffff'>You don't have enough points to purchase this casino.</font>";
}
else{

if ($type == 'Horse Racing'){
  // update new owner
$result = mysql_query("UPDATE location SET rt='".mysql_real_escape_string($buyer_name)."', rt_max='500000', rt_profit='0' WHERE id='".mysql_real_escape_string($location)."'")
or die(mysql_error());
  
echo "<font color='#ffffff'>You now own the ".$location_array[$location]." Horse Racing.</font>";
}
elseif ($type == 'Keno'){
  // update new owner
$result = mysql_query("UPDATE location SET keno='".mysql_real_escape_string($buyer_name)."', keno_max='500000', keno_profit='0' WHERE id='".mysql_real_escape_string($location)."'")
or die(mysql_error());
  
echo "<font color='#ffffff'>You now own the ".$location_array[$location]." Keno.</font>";
}
elseif ($type == 'Shooting Range'){


  // update new owner
$result = mysql_query("UPDATE location SET sr='".mysql_real_escape_string($buyer_name)."', sr_profit='0' WHERE id='".mysql_real_escape_string($location)."'")
or die(mysql_error());
  
echo "<font color='#ffffff'>You now own the ".$location_array[$location]." Shooting Range.</font>";
}
elseif ($type == 'Roulette'){
  // update new owner
$sql = "SELECT name FROM login WHERE id='" .mysql_real_escape_string($_SESSION['user_id']). "' ";
$query = mysql_query($sql) or die(mysql_error());  
$buyer_name = htmlspecialchars($row->name);
  
$result = mysql_query("UPDATE location SET rl='".mysql_real_escape_string($buyer_name)."', rl_max='500000', rl_profit='0' WHERE id='".mysql_real_escape_string($_POST['name3'])."'")
or die(mysql_error());
  
echo "<font color='#ffffff'>You now own the ".$location_array[$location]." Roulette.</font>";
}
elseif ($type == 'Blackjack'){
  // update new owner
$result = mysql_query("UPDATE location SET bj='".mysql_real_escape_string($buyer_name)."', bj_max='500000', bj_profit='0' WHERE id='".mysql_real_escape_string($location)."'")
or die(mysql_error());
  
echo "<font color='#ffffff'>You now own the ".$location_array[$location]." Blackjack.</font>";
}
elseif ($type == 'Travel Agency'){
  // update new owner
$result = mysql_query("UPDATE location SET ta='".mysql_real_escape_string($buyer_name)."', ta_profit='0' WHERE id='".mysql_real_escape_string($location)."'")
or die(mysql_error());
  
echo "<font color='#ffffff'>You now own the ".$location_array[$location]." Travel Agency.</font>";
}
elseif ($type == 'Hospital'){
  // update new owner
$result = mysql_query("UPDATE location SET hs_owner='".mysql_real_escape_string($buyer_name)."', hs_profit='0' WHERE id='".mysql_real_escape_string($location)."'")
or die(mysql_error());
  
echo "<font color='#ffffff'>You now own the ".$location_array[$location]." Hospital.</font>";
}
elseif ($type == 'Bullet Factory'){
  // update new owner
$result = mysql_query("UPDATE location SET bf_owner='".mysql_real_escape_string($buyer_name)."', bf_profit='0' WHERE id='".mysql_real_escape_string($location)."'")
or die(mysql_error());
  
echo "<font color='#ffffff'>You now own the ".$location_array[$location]." Bullet Factory.</font>";
}


//add points to seller
$result = mysql_query("UPDATE login SET credits=credits+'".mysql_real_escape_string($price)."' WHERE name='".mysql_real_escape_string($owner)."'")
or die(mysql_error());

  // remove cash
$result = mysql_query("UPDATE login SET credits=credits-'".mysql_real_escape_string($price)."' WHERE id='" .mysql_real_escape_string($_SESSION['user_id']). "'")
or die(mysql_error());

//reset casino sell
$sql = "DELETE FROM casino_sell WHERE id='".mysql_real_escape_string($_POST['name3'])."' ";
$query = mysql_query($sql) or die(mysql_error());

$owner = $buyer_name;
$credits = $credits - $price;
// if already owned.
}// if not enough points.
}// if post purchase.

?>
 
PHP hulp

PHP hulp

12/11/2024 20:31:45
 
Dennis

Dennis

24/08/2008 23:00:00
Quote Anchor link
Al opgelost,

bij de WHERE waar het casino opgezocht wordt, moest dit komen :

WHERE (casino type)='".mysql_real_escape_string($owner)."'
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.