Raised This Month: $ Target: $400
 0% 

Question about SQLx


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TheRadiance
Senior Member
Join Date: Nov 2007
Location: Kazakhstan
Old 09-09-2008 , 12:16   Question about SQLx
Reply With Quote #1

I have a little problem with sql plugin (using <sqlx>)

My situation:
new Handle:query=SQL_PrepareQuery(sqlx,"Select `column1` from `db` where `column1`='111')

My Problem:if there is no query that contains 111(for example) i will get this:
Code:
L 09/30/2008 - 20:25:38: [MySQL] No result set in this query!
L 09/30/2008 - 20:25:38: [AMXX] Displaying debug trace (plugin "amx_hwid.amxx")
L 09/30/2008 - 20:25:38: [AMXX] Run time error 10: native error (native "SQL_FieldNameToNum")
L 09/30/2008 - 20:25:38: [AMXX]    [0] amx_hwid.sma::client_putinserver (line 80)
How i can avoid it? For example: if there is no query with 111, it will return in player's console that there is now 111(but not debug) and stops function.

Or what format of query request i should user?
thnx.
TheRadiance is offline
Send a message via ICQ to TheRadiance
|PJ| Shorty
Veteran Member
Join Date: Aug 2005
Location: Bavaria, Germany
Old 09-09-2008 , 18:03   Re: Question about SQLx
Reply With Quote #2

what i can see from your error message:
you donīt check if you got a result before you read the result.

see:
http://http://www.amxmodx.org/funcwi...o=func&id=1103
http://www.amxmodx.org/funcwiki.php?go=func&id=1108

what you show me from your code is not enough to say something.
__________________
There are only 10 types of people in the world:
Those who understand binary, and those who donīt.
|PJ| Shorty is offline
Send a message via ICQ to |PJ| Shorty Send a message via AIM to |PJ| Shorty Send a message via MSN to |PJ| Shorty Send a message via Yahoo to |PJ| Shorty Send a message via Skype™ to |PJ| Shorty
TheRadiance
Senior Member
Join Date: Nov 2007
Location: Kazakhstan
Old 09-09-2008 , 21:33   Re: Question about SQLx
Reply With Quote #3

Quote:
what you show me from your code is not enough to say something.
PHP Code:

public client_putinserver(id)
{
    new 
info[32];new _info=get_user_info(id,"*hwID",info,31)
    if((!
_info)||(!get_user_flags(id)&&ADMIN_USER))
        return 
PLUGIN_HANDLED
    
new Handle:query=SQL_PrepareQuery(sqlx,"Select `hwid` from `%s` where `hwid`='%s'",table,info)
    
SQL_Execute(query)
    new 
_col=SQL_FieldNameToNum(query,"hwid")
    new 
buff[32]
    
SQL_ReadResult(query,_col,buff,31)
    if(
equali(buff,""))
        return 
PLUGIN_HANDLED
    server_cmd
("kick #%d [*myAC] You have been banned from this server.",get_user_userid(id))
    
SQL_FreeHandle(query)
    return 
PLUGIN_HANDLED

Quote:
you donīt check if you got a result before you read the result.
How i can do it?
Please, if not hard, can you give me a correct part of code with it?

Last edited by TheRadiance; 09-09-2008 at 21:37.
TheRadiance is offline
Send a message via ICQ to TheRadiance
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 09-09-2008 , 21:46   Re: Question about SQLx
Reply With Quote #4

http://www.amxmodx.org/funcwiki.php?go=func&id=1108
danielkza is offline
|PJ| Shorty
Veteran Member
Join Date: Aug 2005
Location: Bavaria, Germany
Old 09-09-2008 , 22:03   Re: Question about SQLx
Reply With Quote #5

PHP Code:
public client_putinserver(id

    new 
info[32];new _info=get_user_info(id,"*hwID",info,31
    if((!
_info)||(!get_user_flags(id)&&ADMIN_USER)) 
        return 
PLUGIN_HANDLED 
    
new Handle:query=SQL_PrepareQuery(sqlx,"Select `hwid` from `%s` where `hwid`='%s'",table,info
    
SQL_Execute(query)
    while(
SQL_MoreResults(query)) { //execute code as long as you have a result
        //new _col=SQL_FieldNameToNum(query,"hwid") // not needed, _col always 0
        
new buff[32
        
//SQL_ReadResult(query,_col,buff,31)
        
SQL_ReadResult(query,0,buff,31// you only select "hwid", _col = 0
        //if(equali(buff,"")) 
           //return PLUGIN_HANDLED 
        
server_cmd("kick #%d [*myAC] You have been banned from this server.",get_user_userid(id))
        
SQL_NextRow(query//switch to next result
    
}
    
SQL_FreeHandle(query
    return 
PLUGIN_HANDLED 

__________________
There are only 10 types of people in the world:
Those who understand binary, and those who donīt.

Last edited by |PJ| Shorty; 09-09-2008 at 22:10.
|PJ| Shorty is offline
Send a message via ICQ to |PJ| Shorty Send a message via AIM to |PJ| Shorty Send a message via MSN to |PJ| Shorty Send a message via Yahoo to |PJ| Shorty Send a message via Skype™ to |PJ| Shorty
TheRadiance
Senior Member
Join Date: Nov 2007
Location: Kazakhstan
Old 09-10-2008 , 00:57   Re: Question about SQLx
Reply With Quote #6

big thnx, works
TheRadiance is offline
Send a message via ICQ to TheRadiance
Reply


Thread Tools
Display Modes

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 03:05.


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