Raised This Month: $ Target: $400
 0% 

Problem with SQL...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AceDude
Junior Member
Join Date: Jul 2006
Location: Wroclaw, Poland
Old 10-14-2007 , 15:15   Problem with SQL...
Reply With Quote #1

This error is killing me. I have tried to make query in ~5 diffrent ways, but its always same (invalid handle).

Code:
L 10/14/2007 - 21:07:18: [MySQL] Invalid DBI result handle 2
L 10/14/2007 - 21:07:18: [AMXX] Displaying debug trace (plugin "csn-sql.amxx")
L 10/14/2007 - 21:07:18: [AMXX] Run time error 10: native error (native "dbi_nextrow")
L 10/14/2007 - 21:07:18: [AMXX]    [0] csn-sql.sma::client_putinserver (line 112)
Code listing:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <dbi>

#define MAX_PLAYERS 32

new bool:g_restart_attempt[MAX_PLAYERS 1]
new 
Sql:dbc
new plr_points[32]


public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("ResetHUD""event_hud_reset""be")
    
register_clcmd("fullupdate""clcmd_fullupdate"
    
register_event("TextMsg""event_restart_attempt""a""2=#Game_will_restart_in")
    
    
sql_init() 
}

public 
sql_init() {
    new 
host[64], username[32], password[32], dbname[32], error[32]
    
    
get_cvar_string("amx_sql_host"host64)
    
get_cvar_string("amx_sql_user"username32)
    
get_cvar_string("amx_sql_pass"password32)
    
get_cvar_string("amx_sql_db"dbname32)
    
    
dbc dbi_connect(hostusernamepassworddbnameerror32)
    
    if (
dbc SQL_OK)
        
client_print(1print_chat"[AMXX] SQL Connection Failed ")
}

public 
clcmd_fullupdate() {
    return 
PLUGIN_HANDLED_MAIN
}
 
public 
event_restart_attempt() {
    new 
players[32], num
    get_players
(playersnum"a")
    for (new 
inum; ++i)
        
g_restart_attempt[players[i]] = true
}
 
public 
event_hud_reset(id) {
    if (
g_restart_attempt[id]) {
        
g_restart_attempt[id] = false
        
return
    }
    
event_player_spawn(id)
}

public 
client_putinserver(id) {
    new 
steamid[35]
    
get_user_authid(idsteamid34)
   
    new 
sql[255]
    
format(sql,254,"SELECT * FROM amx_csn_users WHERE steam_id = '%s'"steamid)
    
    new 
Result:res dbi_query(dbcsql)
     
    if(!
res)
    {
        
client_print(1print_chat"[AMXX] Blad bazy danych")
    }
    
    while(
dbi_nextrow(Result))
            {
            
plr_points[id] = dbi_result(Result,"points")
        }
    
    
client_print(1print_chat"[AMXX] Na serwer wlazl ktoz ze steamid %s, ma id (%i) oraz %s2 bonusowych punktow"steamididplr_points[id])
}
 
// this function is called on player spawn
public event_player_spawn(id) {
    new 
BONUSKASA id*100
    cs_set_user_money
(idcs_get_user_money(id) + BONUSKASA)
    
client_print(1print_chat"[AMXX] SPAWN: NOWA RUNDA | Jestes zajebisty i dostajesz $%d"BONUSKASA)

__________________
If you need English->Polish translation, PM me.
AceDude is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 10-14-2007 , 22:45   Re: Problem with SQL...
Reply With Quote #2

Not based on your problem, but when using client_print, try using id in the first arg. Cause, you can't be sure that the user at index 1 is always the person using the command/function.


Now, your problem. You are storing the db result to the variable named res. Why are you using Result in the params for dbi_nextrow/dbi_result?
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
AceDude
Junior Member
Join Date: Jul 2006
Location: Wroclaw, Poland
Old 10-15-2007 , 12:16   Re: Problem with SQL...
Reply With Quote #3

1) It is for testing, so its ok.

2) It is here after my last try. It works same is its 'res'...

Any other ideas?
__________________
If you need English->Polish translation, PM me.
AceDude is offline
AceDude
Junior Member
Join Date: Jul 2006
Location: Wroclaw, Poland
Old 10-15-2007 , 12:29   Re: Problem with SQL...
Reply With Quote #4

Ok, as I thought, script is 100% OK, but... i has set wrong db in sql.cfg... rawr...
__________________
If you need English->Polish translation, PM me.
AceDude is offline
Podunk
Senior Member
Join Date: Nov 2005
Location: Florida
Old 10-15-2007 , 17:00   Re: Problem with SQL...
Reply With Quote #5

lols he said rawr
__________________
Check out my website at http://matthewmiller.info
Podunk is offline
Send a message via MSN to Podunk
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 01:21.


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