Shadow Dan
Sh4dowDan
Give shop points to character is not working. Checking how many points i have is null?
post data
Print: - Array
(
[points_char] => [God] Shadow
[points_value] => 7
)
fetching account id from players table
Print: - Array
(
[id] => 7
)
Fetching existing points from znote_accounts
Points calculation:
Print: - Array
(
[Old:] =>
[New:] => 7
[Total:] => 7
)
post data
Print: - Array
(
[points_char] => [God] Shadow
[points_value] => 7
)
fetching account id from players table
Print: - Array
(
[id] => 7
)
Fetching existing points from znote_accounts
Points calculation:
Print: - Array
(
[Old:] =>
[New:] => 7
[Total:] => 7
)
Code:
// Give points to character
if (empty($_POST['points_char']) === false && empty($_POST['points_value']) === false) {
$char = sanitize($_POST['points_char']);
$points = (int)$_POST['points_value'];
data_dump($_POST, false, "post data");
$account = mysql_select_single("SELECT `id` FROM `players` WHERE `name`='$char' LIMIT 1;");
data_dump($account, false, "fetching account id from players table");
$znote_account = mysql_select_single("SELECT `id`, `premium_points` FROM `accounts` WHERE `id`='". $account['id'] ."';");
data_dump($znote_account, false, "Fetching existing points from znote_accounts");
data_dump(
array(
'Old:' => $znote_account['points'],
'New:' => $points,
'Total:' => ($znote_account['points'] + $points)
),
false,
"Points calculation:");
$points += $znote_account['points'];
mysql_update("UPDATE `accounts` SET `premium_points`='$points' WHERE `id`='". $account['id'] ."';");
}