• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[GESIOR2012]Problem with redeem a coupon system.

Croow

learning LUA :)
Joined
Aug 17, 2015
Messages
25
Reaction score
4
Hello, I found that redeem a coupon system:
https://otland.net/threads/gesior2012-redeem-a-coupon-system.236850/
...and im trying to enter it on my server, but I got that error when trying to enter page where I can change a code for PP..
Code:
Parse error: syntax error, unexpected '[' in C:\xampp\htdocs\pages\redeem.php on line 15
line 15 of redeem.php:
Code:
$result = $query->fetchAll(PDO::FETCH_ASSOC)[0];
full code of redeem.php:
PHP:
<?php
if(!defined('INITIALIZED'))
    exit;
if($logged){
  if(isset($_POST['code'])) {

    $code =  $SQL->quote($_POST['code']);
    $query = $SQL->query('SELECT * FROM `__cornex_redeem` WHERE `code` = '.$code.' LIMIT 1;');



    // Key exist in database
    if ($query->rowCount() >= 1) {
      // $query = $query[0];
      $result = $query->fetchAll(PDO::FETCH_ASSOC)[0];

      if ($result['used_by'] > 0) {
        $error[] = 'Key has already been used';
      }

      if (!empty($error)) {

        foreach ($error as $err) {
          echo $err.'<br>';
        }

      }


      if (empty($error)) {
        $time = time();
        $code = $result['code'];
        $points = $result['points'];
        $querys = sprintf('UPDATE `__cornex_redeem` SET `time`='.time().', `used_by`='.$account_logged->getId().' WHERE `code`="'.$result['code'].'" ');
        $SQL->query($querys);
        $account_logged->setPremiumPoints($account_logged->getPremiumPoints() + $points);
        $account_logged->save();

        echo 'Amount of '.$points.' points has been added to your account!';
      }

    } else {
      echo 'Key is not valid';
    }

  }
$accid = $account_logged->getID();
$main_content .= '
<form action="" method="POST">

    <input type="text" name="code">
    <input type="submit" value="Redeem">

</form>';
} else {
    $main_content .= '
<div class="ui warning message">
  <div class="header">
    You dont have permission to do that!
  </div>
</div>
    ';
}
Thanks in Advance for help.

Im using Gesior2012.
 
Back
Top