AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   SQLx module bug. How to avoid it? (https://forums.alliedmods.net/showthread.php?t=108619)

10000000 11-07-2009 14:29

SQLx module bug. How to avoid it?
 
Occurs something really weird. Lets suppose I got this code:
PHP Code:

public retrieve_bans(id)
{
    new 
error[512], errno
    
new Handle:sql SQL_Connect(g_infoerrnoerror127)
    new 
Handle:query
    
for(new pcount2 0pcount2 <= 4pcount2++)
    {
        
query SQL_PrepareQuery(sql,"SELECT `data6` FROM `characters` WHERE pj = '%s'"g_pj[pcount2][id])
        if (!
SQL_Execute(query))
        {
            
server_cmd("kick #%d ^"Servidor muy ocupado^""get_user_userid(id)) //kick him!
            
SQL_FreeHandle(query)
            
SQL_FreeHandle(sql)
            return 
PLUGIN_HANDLED
        
}
        else 
        {
            
SQL_NumResults(query)
            
g_pjban[pcount2][id] = SQL_ReadResult(query0)
        }
    }
    
SQL_FreeHandle(query)
    
SQL_FreeHandle(sql)
    return 
PLUGIN_HANDLED


Everything works fine.
But lets suppose I change the query from this
PHP Code:

query SQL_PrepareQuery(sql,"SELECT `data6` FROM `characters` WHERE pj = '%s'"g_pj[pcount2][id]) 

To this
PHP Code:

query SQL_PrepareQuery(sql,"SELECT `bantime` FROM `characters` WHERE pj = '%s'"g_pj[pcount2][id]) 

Everything should work fine, as it does when I insert that query direct into phpMyAdmin. I just get another value from another column. Weirdly, in SQLx module it throws an annoying error

Code:

L 11/07/2009 - 15:11:41: [MySQL] No result set in this query!
L 11/07/2009 - 15:11:41: [AMXX] Displaying debug trace (plugin "test.amxx")
L 11/07/2009 - 15:11:41: [AMXX] Run time error 10: native error (native "SQL_ReadResult")

Any idea of this weird bug?

Exolent[jNr] 11-07-2009 14:31

Re: SQLx module bug. How to avoid it?
 
PHP Code:

        else 
        {
            
SQL_NumResults(query

:arrow:
PHP Code:

        else if (SQL_NumResults(query))
        { 


10000000 11-07-2009 14:36

Re: SQLx module bug. How to avoid it?
 
Quote:

Originally Posted by Exolent[jNr] (Post 983303)
PHP Code:

        else 
        {
            
SQL_NumResults(query

:arrow:
PHP Code:

        else if (SQL_NumResults(query))
        { 


Anyway still occurs. And should always return a value.
I fixed this by creating another column which doesn't seem to be affected by this bug. Maybe just the module didn't liked the name bantime, since after changing it to ban it works.

10000000 11-07-2009 14:43

Re: SQLx module bug. How to avoid it?
 
Damn, now the error comes again, well, it doesn't, but it just doesn't get the desired value because it stops here
PHP Code:

else if (SQL_NumResults(query)) 
        { 

Why the hell is SQLx not getting the value, and phpMyAdmin is?

10000000 11-07-2009 14:51

Re: SQLx module bug. How to avoid it?
 
Ok, its fixed now.
I optimized, analysed, repaired, revised and all that stuff the table and now works fine. Weird, isn't it?


All times are GMT -4. The time now is 17:47.

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