Jump to content
  • 0

query_sql problem


Limestone

Question


  • Group:  Members
  • Topic Count:  155
  • Topics Per Day:  0.03
  • Content Count:  647
  • Reputation:   16
  • Joined:  11/21/11
  • Last Seen:  

Hi! i always got DB Error - Data truncated for column `balance` at row 1

 

i dont know what to do, here's my script

 

            mes "You have a total of "+#VOTEPOINTS+" Vote Points.";
            mes "Would you like to convert it to credits?";
            mes "^ff0000Note:^000000 1 Vote Points = 1 Credits.";
            next;
            switch(select("Let me think first.:Yes, let's continue.")){
            case 1:
                    mes .npcName$;
                    mes "Come back if you already want to talk to me.";
                    close;
            case 2:
                    if(#VOTEPOINTS < 1){
                    mes .npcName$;
                    mes "You don't have enough Vote Points to convert.";
                    close;
                    }
                    else {
                    mes .npcName$;
                    mes "Put your desired amount to be converted.";
                    }
                    input @vote,0,#VOTEPOINTS;
                    
                    if( @vote < #VOTEPOINTS ){
                        next;
                        mes .npcName$;
                        mes "Not enough Vote Points.";
                        close;
                    }
                    else {
                        next;
                        mes .npcName$;
                        mes "Thank you! and come again.";
                        query_sql "UPDATE `cp_credits` SET `balance` = `balance` + @vote WHERE `account_id` = "+ getcharid(3) +" AND `balance` <> 0;";
                        set #VOTEPOINTS,#VOTEPOINTS-@vote;
                        close;
                }
        }
Link to comment
Share on other sites

8 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  181
  • Reputation:   53
  • Joined:  04/07/13
  • Last Seen:  

I think the query should look like this:

query_sql "UPDATE `cp_credits` SET `balance` = `balance` + " + @vote + " WHERE `account_id` = " + getcharid(3) + " AND `balance` <> 0;";

 

 

 

someone knows wtf  

 

AND `balance` <> 0;

means?

 

<> is the operator for "not equal", the same as !=

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  17
  • Topics Per Day:  0.00
  • Content Count:  76
  • Reputation:   3
  • Joined:  02/24/12
  • Last Seen:  

someone knows wtf  

AND `balance` <> 0;

means?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  17
  • Topics Per Day:  0.00
  • Content Count:  76
  • Reputation:   3
  • Joined:  02/24/12
  • Last Seen:  

I think the query should look like this:

query_sql "UPDATE `cp_credits` SET `balance` = `balance` + " + @vote + " WHERE `account_id` = " + getcharid(3) + " AND `balance` <> 0;";

 

 

 

someone knows wtf  

 

AND `balance` <> 0;

means?

 

<> is the operator for "not equal", the same as !=

ahh thanks :D

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  155
  • Topics Per Day:  0.03
  • Content Count:  647
  • Reputation:   16
  • Joined:  11/21/11
  • Last Seen:  

it worked, thanks!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  155
  • Topics Per Day:  0.03
  • Content Count:  647
  • Reputation:   16
  • Joined:  11/21/11
  • Last Seen:  

I think the query should look like this:

query_sql "UPDATE `cp_credits` SET `balance` = `balance` + " + @vote + " WHERE `account_id` = " + getcharid(3) + " AND `balance` <> 0;";

 

 

 

someone knows wtf  

 

AND `balance` <> 0;

means?

 

<> is the operator for "not equal", the same as !=

 

Hi! i got problems when updating the cp_credits, i wiped out my server, then i try to vote, when i try to convert my votepoints to credits, it doesnt updating. please help.

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

I think the query should look like this:

query_sql "UPDATE `cp_credits` SET `balance` = `balance` + " + @vote + " WHERE `account_id` = " + getcharid(3) + " AND `balance` <> 0;";

 

 

 

someone knows wtf  

 

AND `balance` <> 0;

means?

 

<> is the operator for "not equal", the same as !=

 

Hi! i got problems when updating the cp_credits, i wiped out my server, then i try to vote, when i try to convert my votepoints to credits, it doesnt updating. please help.

 

Because update only works if there is something in the database to edit...

 

		query_sql "SELECT `account_id` FROM `cp_credits` WHERE `account_id` = "+getcharid(3)+";",.@a;
		mes "You have a total of "+#VOTEPOINTS+" Vote Points.";
		mes "Would you like to convert it to credits?";
		mes "^ff0000Note:^000000 1 Vote Points = 1 Credits.";
		next;
		switch(select("Let me think first.:Yes, let's continue.")) {
		case 1:
				mes .npcName$;
				mes "Come back if you already want to talk to me.";
				close;
		case 2:
			if(#VOTEPOINTS < 1) {
				mes .npcName$;
				mes "You don't have enough Vote Points to convert.";
				close;
			} else {
				mes .npcName$;
				mes "Put your desired amount to be converted.";
			}
			input @vote,0,#VOTEPOINTS;

			if( @vote < #VOTEPOINTS ) {
				next;
				mes .npcName$;
				mes "Not enough Vote Points.";
				close;
			} else {
				next;
				mes .npcName$;
				mes "Thank you! and come again.";
				if(.@a) query_sql "UPDATE `cp_credits` SET `balance` = `balance` + " + @vote + " WHERE `account_id` = " + getcharid(3) + " AND `balance` <> 0;";
				else query_sql "INSERT INTO `cp_credits` (account_id, balance) VALUES ("+getcharid(3)+", "+@vote+")";
				set #VOTEPOINTS,#VOTEPOINTS-@vote;
				close;
			}
		}
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  155
  • Topics Per Day:  0.03
  • Content Count:  647
  • Reputation:   16
  • Joined:  11/21/11
  • Last Seen:  

Hi

 

 

I think the query should look like this:

query_sql "UPDATE `cp_credits` SET `balance` = `balance` + " + @vote + " WHERE `account_id` = " + getcharid(3) + " AND `balance` <> 0;";

 

 

 

someone knows wtf  

 

AND `balance` <> 0;

means?

 

<> is the operator for "not equal", the same as !=

 

Hi! i got problems when updating the cp_credits, i wiped out my server, then i try to vote, when i try to convert my votepoints to credits, it doesnt updating. please help.

 

Because update only works if there is something in the database to edit...

 

		query_sql "SELECT `account_id` FROM `cp_credits` WHERE `account_id` = "+getcharid(3)+";",.@a;
		mes "You have a total of "+#VOTEPOINTS+" Vote Points.";
		mes "Would you like to convert it to credits?";
		mes "^ff0000Note:^000000 1 Vote Points = 1 Credits.";
		next;
		switch(select("Let me think first.:Yes, let's continue.")) {
		case 1:
				mes .npcName$;
				mes "Come back if you already want to talk to me.";
				close;
		case 2:
			if(#VOTEPOINTS < 1) {
				mes .npcName$;
				mes "You don't have enough Vote Points to convert.";
				close;
			} else {
				mes .npcName$;
				mes "Put your desired amount to be converted.";
			}
			input @vote,0,#VOTEPOINTS;

			if( @vote < #VOTEPOINTS ) {
				next;
				mes .npcName$;
				mes "Not enough Vote Points.";
				close;
			} else {
				next;
				mes .npcName$;
				mes "Thank you! and come again.";
				if(.@a) query_sql "UPDATE `cp_credits` SET `balance` = `balance` + " + @vote + " WHERE `account_id` = " + getcharid(3) + " AND `balance` <> 0;";
				else query_sql "INSERT INTO `cp_credits` (account_id, balance) VALUES ("+getcharid(3)+", "+@vote+")";
				set #VOTEPOINTS,#VOTEPOINTS-@vote;
				close;
			}
		}

 

Thanks! it worked, but i have notice that there is a problem, for example, i have 10 Vote Points, and i only want to convert 8 Points, it says i dont have enough vote points, but if i put the exact amount of my vote points, the npc will accept my input and then it will convert it.

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

if( @vote < #VOTEPOINTS ) {
	next;
	mes .npcName$;
	mes "Not enough Vote Points.";
	close;
}

you dont need this. ....

the input script command already limiting what number you can enter ..

input @vote,0,#VOTEPOINTS;
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...