• 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!

[Znote AAC] Redeem a coupon system

OP
Cornex

Cornex

Web Developer
Staff member
Global Moderator
Joined
Jun 15, 2008
Messages
3,447
Solutions
5
Reaction score
1,163
Location
Sweden
The problem here is simple, it tries to insert as integer to a integer column when it should be inserted as a string.
What we have to do here, is first of change the SQL column `used_by` to not be integer, do so by run this:

Code:
ALTER TABLE __cornex_redeem
MODIFY COLUMN used_by varchar(35)

When that is done, you have to open file redeem.php and change line

PHP:
$query = "UPDATE `__cornex_redeem` SET `used_by` = $used_by , `time` = $time , `ip` = $ip WHERE `code` = '$code'";

To

PHP:
$query = "UPDATE `__cornex_redeem` SET `used_by` = '$used_by' , `time` = $time , `ip` = $ip WHERE `code` = '$code'";

@Mariuskens , @kushovu , @calveron

Inserting a string value to a integer field should stand in above post. Sleep is for the weak.
 
Last edited by a moderator:

Mariuskens

Sword Art Online 2D-MMORPG
Joined
Nov 21, 2008
Messages
1,001
Reaction score
107
Location
Spain
GitHub
Olimpotibia
about ur reply same issue :S

string(129) "UPDATE `__cornex_redeem` SET `used_by` = '2422324' , `time` = 1430816020 , `ip` = WHERE `code` = 'BB37-ZR38-52YX-14PG-COCY-82UK'"
(query - SQL error)
Type: voidQuery (voidQuery is used for update, insert or delete from database)

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `code` = 'BB37-ZR38-52YX-14PG-COCY-82UK'' at line 1
 
OP
Cornex

Cornex

Web Developer
Staff member
Global Moderator
Joined
Jun 15, 2008
Messages
3,447
Solutions
5
Reaction score
1,163
Location
Sweden
about ur reply same issue :S

string(129) "UPDATE `__cornex_redeem` SET `used_by` = '2422324' , `time` = 1430816020 , `ip` = WHERE `code` = 'BB37-ZR38-52YX-14PG-COCY-82UK'"
(query - SQL error)
Type: voidQuery (voidQuery is used for update, insert or delete from database)

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `code` = 'BB37-ZR38-52YX-14PG-COCY-82UK'' at line 1

That is another issue, the ip seems to return nothing. I can help you via teamviewer, please send me a PM.
 

kushovu

NXA
Joined
Jan 27, 2009
Messages
75
Reaction score
13
same error as @Mariuskens

string(126) "UPDATE `__cornex_redeem` SET `used_by` = 'vamp' , `time` = 1430863914 , `ip` = WHERE `code` = 'WW78-KK67-94DD-23MC-NWRF-44FP'"
(query - SQL error)
Type: voidQuery (voidQuery is used for update, insert or delete from database)

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `code` = 'WW78-KK67-94DD-23MC-NWRF-44FP'' at line 1
 
OP
Cornex

Cornex

Web Developer
Staff member
Global Moderator
Joined
Jun 15, 2008
Messages
3,447
Solutions
5
Reaction score
1,163
Location
Sweden
same error as @Mariuskens

string(126) "UPDATE `__cornex_redeem` SET `used_by` = 'vamp' , `time` = 1430863914 , `ip` = WHERE `code` = 'WW78-KK67-94DD-23MC-NWRF-44FP'"
(query - SQL error)
Type: voidQuery (voidQuery is used for update, insert or delete from database)

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `code` = 'WW78-KK67-94DD-23MC-NWRF-44FP'' at line 1

I can take a look at it over teamviewer, or if you can dump the output of getIP() function and send it here.
 

EvulMastah

๏̯͡๏﴿
Premium User
Joined
Aug 19, 2007
Messages
4,848
Reaction score
257
Why are you altering a table after creating it? You can do all of that in the creation process.
 
OP
Cornex

Cornex

Web Developer
Staff member
Global Moderator
Joined
Jun 15, 2008
Messages
3,447
Solutions
5
Reaction score
1,163
Location
Sweden
Why are you altering a table after creating it? You can do all of that in the creation process.

Yeah I know, because I created the table and forgot to add primary key. I added it after I created the table.
So once I generate the MySQL code, as the lazy bitch I am they wrote it like that. :)
 
OP
Cornex

Cornex

Web Developer
Staff member
Global Moderator
Joined
Jun 15, 2008
Messages
3,447
Solutions
5
Reaction score
1,163
Location
Sweden
same error as @Mariuskens

string(126) "UPDATE `__cornex_redeem` SET `used_by` = 'vamp' , `time` = 1430863914 , `ip` = WHERE `code` = 'WW78-KK67-94DD-23MC-NWRF-44FP'"
(query - SQL error)
Type: voidQuery (voidQuery is used for update, insert or delete from database)

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `code` = 'WW78-KK67-94DD-23MC-NWRF-44FP'' at line 1

Fixed it, simply replace your currently redeem.php with this: http://pastebin.com/raw.php?i=dC0ZMF4q
 

kushovu

NXA
Joined
Jan 27, 2009
Messages
75
Reaction score
13
Its fixed now and it add your points but you can use it as many times you want
 

raf

Active Member
Joined
Jan 10, 2011
Messages
260
Reaction score
37
Location
Warsaw, PL
Gesior version
PHP:
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @[email protected]@CHARACTER_SET_CLIENT */;
/*!40101 SET @[email protected]@CHARACTER_SET_RESULTS */;
/*!40101 SET @[email protected]@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
CREATE TABLE IF NOT EXISTS `__cornex_redeem` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `points` int(11) NOT NULL,
  `used_by` int(11) NOT NULL DEFAULT '0',
  `time` int(11) NOT NULL,
  `ip` int(11) NOT NULL,
  `code` varchar(100) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
/*!40101 SET [email protected]_CHARACTER_SET_CLIENT */;
/*!40101 SET [email protected]_CHARACTER_SET_RESULTS */;
/*!40101 SET [email protected]_COLLATION_CONNECTION */;

admincoupon.php
PHP:
<?php
if(!defined('INITIALIZED'))
    exit;

if($group_id_of_acc_logged >= $config['site']['access_admin_panel']){
    function serialKey()
    {
        $chars = array(0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
        $serial = '';
        $max = count($chars)-1;
        for($i=0;$i<20;$i++){
            $serial .= (!($i % 5) && $i ? '-' : '').$chars[rand(0, $max)];
        }
        return $serial;
    }

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

        $error = false;
        $points = $_POST['points'];

        if (empty($points)) {
            $error[] = "<font color='red'>Field cannot be empty</font>";
        }

        if (!is_numeric($points)) {
            $error[] = "<font color='red'>Must be a number value</font>";
        }

        if (!empty($error)) {

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

        }


        if (empty($error)) {
            // Success
            $key = serialKey();
            $SQL->query('INSERT INTO `__cornex_redeem` (`code`, `points`, `used_by`, `time`, `ip`) VALUES ('.$SQL->quote($key).','.$points.', 0, 0, 0)');
            echo '<p><b>Key generated</b><font color="red">: '.$key.'</font></p>';
        }

    }

$main_content .= '
<form class="ui form" action="" method="POST">

    <div class="six wide field">
    <label>Points</label>
    <input type="text" name="points" placeholder="Amount of points for this code">
  </div>
    <input class="ui submit button" type="submit" value="Create code">

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

redeem.php
PHP:
still working on it...
 
OP
Cornex

Cornex

Web Developer
Staff member
Global Moderator
Joined
Jun 15, 2008
Messages
3,447
Solutions
5
Reaction score
1,163
Location
Sweden

Should be: (cannot edit that shit)

Thanks for your work, you know this line can be written like:

PHP:
$chars = array_merge(range(0, 9), range('A', 'Z'));

Cheers! :)
 

raf

Active Member
Joined
Jan 10, 2011
Messages
260
Reaction score
37
Location
Warsaw, PL
Should be: (cannot edit that shit)

Thanks for your work, you know this line can be written like:

PHP:
$chars = array_merge(range(0, 9), range('A', 'Z'));

Cheers! :)
Now i know :D It's taken as raw code from stackoverflow. Later on will try to make redeem work
 
OP
Cornex

Cornex

Web Developer
Staff member
Global Moderator
Joined
Jun 15, 2008
Messages
3,447
Solutions
5
Reaction score
1,163
Location
Sweden
Now i know :D It's taken as raw code from stackoverflow. Later on will try to make redeem work

How is the redeem going for GesiorAAC, can I help you with anything? :)
 
Top