Virtue Posted January 16, 2013 Group: Members Topic Count: 92 Topics Per Day: 0.02 Content Count: 354 Reputation: 22 Joined: 11/17/11 Last Seen: May 12, 2024 Share Posted January 16, 2013 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)) Quote Link to comment Share on other sites More sharing options...
KeyWorld Posted January 16, 2013 Group: Members Topic Count: 9 Topics Per Day: 0.00 Content Count: 379 Reputation: 304 Joined: 11/10/11 Last Seen: December 2, 2014 Share Posted January 16, 2013 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')"); 1 Quote Link to comment Share on other sites More sharing options...
Virtue Posted January 16, 2013 Group: Members Topic Count: 92 Topics Per Day: 0.02 Content Count: 354 Reputation: 22 Joined: 11/17/11 Last Seen: May 12, 2024 Author Share Posted January 16, 2013 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 + "')"); Quote Link to comment Share on other sites More sharing options...
KeyWorld Posted January 16, 2013 Group: Members Topic Count: 9 Topics Per Day: 0.00 Content Count: 379 Reputation: 304 Joined: 11/10/11 Last Seen: December 2, 2014 Share Posted January 16, 2013 Yeah it should. But you don't need escape_sql() on an INT variable just on string. 1 Quote Link to comment Share on other sites More sharing options...
Virtue Posted January 16, 2013 Group: Members Topic Count: 92 Topics Per Day: 0.02 Content Count: 354 Reputation: 22 Joined: 11/17/11 Last Seen: May 12, 2024 Author Share Posted January 16, 2013 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); Quote Link to comment Share on other sites More sharing options...
AnnieRuru Posted January 16, 2013 Group: Members Topic Count: 18 Topics Per Day: 0.00 Content Count: 2044 Reputation: 682 Joined: 10/09/12 Last Seen: December 20, 2020 Share Posted January 16, 2013 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; } 1 Quote Link to comment Share on other sites More sharing options...
Virtue Posted January 16, 2013 Group: Members Topic Count: 92 Topics Per Day: 0.02 Content Count: 354 Reputation: 22 Joined: 11/17/11 Last Seen: May 12, 2024 Author Share Posted January 16, 2013 Thanks Annie. this will help alot, im currently improving my know how on sql scripts. Quote Link to comment Share on other sites More sharing options...
Question
Virtue
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))
Link to comment
Share on other sites
6 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.