PDO Buy iteam for 120 i have 100 and i get iteam money left -20 :/

36 viewsSoftware & Technology
0
0 Comments

if (isset($_GET[‘buy’]))
{
if (empty($_GET[‘buy’])) show_error(‘Choose what you want to buy.’);
elseif (array_key_exists($_GET[‘buy’], $food) == FALSE) show_error(‘There is no such product.’);
{
if (isset($_GET[‘buy’]) and isset($_GET[‘ok’]))
{
if ($u[‘hp’] == $u[‘max_hp’]) show_error(‘Your HP Full.’);
elseif ($u[$food[$_GET[‘buy’]][‘price’]] < $food[$_GET[‘buy’]][‘price’]]) show_error(‘You no can’t buy it no have money.’);
else
{
$hp = $u[‘max_hp’] * ($food[$_GET[‘buy’]][‘what’] / 100);
$sql = ‘UPDATE users SET '.$food[$_GET['buy']]['type'].' = '.$food[$_GET['buy']]['type'].' + ?, '.$food[$_GET['buy']]['price'].' = '.$food[$_GET['buy']]['price'].' – ? WHERE id = ?’;
$stmt = $go -> prepare($sql);
$stmt -> execute([$hp, $food[$_GET[‘buy’]][‘amount’], $uid]);
$_SESSION[‘success’] = ‘You have successfully eaten food.’;
die(header(‘Location: ?’));
}
}
else
{

The problem with minus money.

Example – price product 120 i have 100 and i buy this iteam and i have -20money :/

No call error for i no have money and no cant buy iteam for his sell 120 i have 100. Thx you will help me.

Changed status to publish