AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP]Invalid dbi handle 0 (https://forums.alliedmods.net/showthread.php?t=83937)

dxteam 01-17-2009 19:35

[HELP]Invalid dbi handle 0
 
i have this error and don`t know how to fix that..
Code:


L 01/18/2009 - 02:26:25: [MySQL] Invalid DBI handle 0
L 01/18/2009 - 02:26:25: [AMXX] Displaying debug trace (plugin "reg.amxx")
L 01/18/2009 - 02:26:25: [AMXX] Run time error 10: native error (native "dbi_query")
L 01/18/2009 - 02:26:25: [AMXX]    [0] module.inc::login (line 478)
L 01/18/2009 - 02:26:25: [AMXX]    [1] module.inc::client_infochanged (line 384)
L 01/18/2009 - 02:26:33: [MySQL] Invalid DBI handle 0
L 01/18/2009 - 02:26:33: [AMXX] Displaying debug trace (plugin "reg.amxx")
L 01/18/2009 - 02:26:33: [AMXX] Run time error 10: native error (native "dbi_query")
L 01/18/2009 - 02:26:33: [AMXX]    [0] module.inc::login (line 478)
L 01/18/2009 - 02:26:33: [AMXX]    [1] module.inc::client_infochanged (line 384)

-----------------------------
login script 473-492 strings

PHP Code:

public login(name[],pass[])
{
    new 
hash[34]
    
md5(pass,hash)
    {
        new 
Result:result dbi_query(gMySQL,"SELECT * FROM %s WHERE name like '%s' and pass like BINARY '%s'"USER_TABLEnamehash)
        if(
result <=RESULT_FAILED)
        {
            
dbi_free_result(result)
            return 
1
        
}
        
result dbi_query(gMySQL,"SELECT * FROM %s WHERE name like '%s' and pass like BINARY '%s'"WAITING_TABLEnamehash)
        if(
result <=RESULT_FAILED)
        {
            
dbi_free_result(result)
            return -
2
        
}
    }
    return -
1


client_infochanged 374-397 strings

PHP Code:

public client_infochanged(id)
{
    new 
newName[32], oldName[32], pass[35], details[2], bool:changeName false
    get_user_name
(id,oldName,31)
    
get_user_info(id"name"newName,31)
    
get_user_info(idPASSWORD_FIELDpass34)
    
details[0] = id

    
if(!equali(oldName,newName))
        
changeName true
    
if (login(newNamepass) > 0)
    {
        if(
changeName)
            
set_task(5.0,"completeLoginWrapper",470+id,details,1)
        return 
PLUGIN_CONTINUE
    
}

    if(
contain(newNameRESERVED_UNREGISTERED_TEXT) == -1)
    {        
        
server_cmd("kick #%d Register to access this server."get_user_userid(id))
    }

    return 
PLUGIN_CONTINUE



Sn!ff3r 01-17-2009 21:06

Re: [HELP]Invalid dbi handle 0
 
Quote:

if(result <=RESULT_FAILED)
to
Quote:

if(result > RESULT_NONE)

dxteam 01-18-2009 12:40

Re: [HELP]Invalid dbi handle 0
 
Doesn`t work =(
I attach this plugin.
When i start dedicated server and connect, plugin doesn`t work and send error:

Code:

L 01/18/2009 - 19:36:56: [MySQL] Invalid DBI handle 0
L 01/18/2009 - 19:36:56: [AMXX] Displaying debug trace (plugin "userregver3.amxx")
L 01/18/2009 - 19:36:56: [AMXX] Run time error 10: native error (native "dbi_query")
L 01/18/2009 - 19:36:56: [AMXX]    [0] userregver3.sma::login (line 245)
L 01/18/2009 - 19:36:56: [AMXX]    [1] userregver3.sma::client_infochanged (line 151)
L 01/18/2009 - 19:36:56: [MySQL] Invalid DBI handle 0
L 01/18/2009 - 19:36:56: [AMXX] Displaying debug trace (plugin "userregver3.amxx")
L 01/18/2009 - 19:36:56: [AMXX] Run time error 10: native error (native "dbi_query")
L 01/18/2009 - 19:36:56: [AMXX]    [0] userregver3.sma::login (line 245)
L 01/18/2009 - 19:36:56: [AMXX]    [1] userregver3.sma::client_infochanged (line 151)
L 01/18/2009 - 19:36:58: [MySQL] Invalid DBI handle 0
L 01/18/2009 - 19:36:58: [AMXX] Displaying debug trace (plugin "userregver3.amxx")
L 01/18/2009 - 19:36:58: [AMXX] Run time error 10: native error (native "dbi_query")
L 01/18/2009 - 19:36:58: [AMXX]    [0] userregver3.sma::login (line 245)
L 01/18/2009 - 19:36:58: [AMXX]    [1] userregver3.sma::client_infochanged (line 151)

-----------------------------
But when i restart server plugin work correctly!! When i change map plugin work correctly.It don`t work when i start a dedicated server.
Someone please help.

|PJ| Shorty 01-18-2009 22:35

Re: [HELP]Invalid dbi handle 0
 
What do you want to hash with the results, name exists in the db or not?

i´m not really expired with dbi, but try:
PHP Code:

public login(name[],pass[]) 

    new 
hash[34
    
md5(pass,hash
    { 
        new 
Result:result dbi_query(gMySQL,"SELECT * FROM %s WHERE name like '%s' and pass like BINARY '%s'"USER_TABLEnamehash
        if(
result <= RESULT_NONE
        { 
            
dbi_free_result(result
            return 

        
}
        
result dbi_query(gMySQL,"SELECT * FROM %s WHERE name like '%s' and pass like BINARY '%s'"WAITING_TABLEnamehash
        if(
result <= RESULT_NONE
        { 
            
dbi_free_result(result
            return -

        
}
    } 
    return -



also what i always do: open sql_init() from plugin_cfg() with a little delay (like 0.5)
PHP Code:

public plugin_cfg()
{
   
set_task(0.5,"sql_init")
}
public 
sql_init()
{
... 

so you can make sure all cvars loaded

dxteam 01-19-2009 06:19

Re: [HELP]Invalid dbi handle 0
 
thx for helping |PJ| Shorty!!!
I find solution for this error.


All times are GMT -4. The time now is 01:54.

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