Jump to content
  • 0

SQL Script support


Question

Posted

Hi, I am making myself an SQL Script,

now, how do i insert the character name to the sql_query? tried putting the exact name there but i got an error?

INSERT INTO `points` (char_id,name,points) VALUES (150000,????,1)

will it work if i made it like this

query_sql (INSERT INTO `points` (char_id,name,points) VALUES (150000,strcharinfo(0),1))

6 answers to this question

Recommended Posts

Posted

First you have to put QUOTE.

Second you have to secure the string entry.

query_sql("INSERT INTO `points` ( `char_id`, `name`, `points`) VALUES ('150000', '" + escale_sql(strcharinfo(0)) + "', '1')");

  • Upvote 1
Posted

will try that thanks

so assuming that there is no value at all would this be correct?

query_sql("INSERT INTO `points` ( `char_id`, `name`, `points`) VALUES ('" + escale_sql(getcharid(0)) + "', '" + escale_sql(strcharinfo(0)) + "', '"+ .@points + "')");

Posted

alright.

so

query_sql("INSERT INTO `points` ( `char_id`, `name`, `points`) VALUES ('" + getcharid(0) + "', '" + escale_sql(strcharinfo(0)) + "', '"+ .@points + "')");

then when updating the sql db

it should be like this right

query_sql("UPDATE points SET points = ( points + " + .@points  + " ) WHERE char_id = "+getcharid(0);

Posted

meh only teach advance scripting techniques xD

create table test_point (
char_id int(11) unsigned primary key,
name varchar(24),
points int(11),
key (name)
) engine = innodb;

prontera,155,182,4	script	kjsdfksdjfhs	100,{
query_sql "select points from test_point where char_id = "+ getcharid(0), .@points;
mes "you currently have "+ .@points +" points";
close;
OnNPCKillEvent:
if ( killedrid != 1002 ) end;
.@points = rand(10);
query_sql "insert into test_point values ( "+ getcharid(0) +", '"+ escape_sql( strcharinfo(0) ) +"', "+ .@points +" ) on duplicate key update points = points + "+ .@points;
end;
}

  • Upvote 1

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...