Raised This Month: $ Target: $400
 0% 

SQLx module bug. How to avoid it?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
10000000
BANNED
Join Date: Oct 2009
Old 11-07-2009 , 14:29   SQLx module bug. How to avoid it?
Reply With Quote #1

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?
10000000 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-07-2009 , 14:31   Re: SQLx module bug. How to avoid it?
Reply With Quote #2

PHP Code:
        else 
        {
            
SQL_NumResults(query

PHP Code:
        else if (SQL_NumResults(query))
        { 
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
10000000
BANNED
Join Date: Oct 2009
Old 11-07-2009 , 14:36   Re: SQLx module bug. How to avoid it?
Reply With Quote #3

Quote:
Originally Posted by Exolent[jNr] View Post
PHP Code:
        else 
        {
            
SQL_NumResults(query

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 is offline
10000000
BANNED
Join Date: Oct 2009
Old 11-07-2009 , 14:43   Re: SQLx module bug. How to avoid it?
Reply With Quote #4

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 is offline
10000000
BANNED
Join Date: Oct 2009
Old 11-07-2009 , 14:51   Re: SQLx module bug. How to avoid it?
Reply With Quote #5

Ok, its fixed now.
I optimized, analysed, repaired, revised and all that stuff the table and now works fine. Weird, isn't it?
10000000 is offline
Reply



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 17:47.


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