Raised This Month: $ Target: $400
 0% 

SQL sending killer id to SQL Query


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
devWaleed
Member
Join Date: Apr 2013
Location: Karachi, Pakistan
Old 08-08-2014 , 19:22   SQL sending killer id to SQL Query
Reply With Quote #1

OK, as the first rule I tried myself and learned basics of this SQLx working. It is (almost) working but there is a little problem passing the killer id to sql query. Look here:

In DeathEvent:

PHP Code:
//I made killer a global var to make it reach the subthread of query but it doesn't work.
killer read_data(1);
    
username[killer] = get_user_name(killernamecharsmax(name));        
formatex(Query511"SELECT * FROM points WHERE `username`='%s'"username[killer]);        
SQL_ThreadQuery(g_SqlTuple"QueryThread_SELECT"Query); 


This works and I can reach next step without errors:



PHP Code:
public QueryThread_SELECT(FailStateHandle:QueryError[], ErrcodeData[], DataSize){
    
    if(
FailState == TQUERY_CONNECT_FAILED){
        return 
set_fail_state("Couldn't connect to DB");        
    }else if(
FailState == TQUERY_QUERY_FAILED){
        return 
set_fail_state("Query failed");
    }
    
    if(
SQL_NumResults(Query) < 1){
        
//I assume from tutorial that NumResults returns the selected rows, if 0 means no previous entry
        
formatex(szquery511"INSERT INTO `points` VALUES('%s', '+1')"username[killer]);
        
SQL_ThreadQuery(g_SqlTuple"FreeQueryHandler"szquery);
    }else if(
SQL_NumResults(Query) == 1){
               
//and if ==1 means there is previous entry, so +1 in last entry.
        
formatex(szquery511"UPDATE `points` SET `coins` = '+1' WHERE `username` = '%s'"username[killer]);
        
SQL_ThreadQuery(g_SqlTuple"FreeQueryHandler"szquery);
    }
    return 
PLUGIN_CONTINUE;

Results are:

I get 1 point data entered in MYSQL db but with empty 'username' field and after, it doesn't update. I think it has to do with that Data[] paramter right? Please show me...
__________________
Steam: Waleedbaig2013
devWaleed is offline
Send a message via Skype™ to devWaleed
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:57.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode