Raised This Month: $ Target: $400
 0% 

SQL_PrepareQuery Run Time Error 10


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Russianeer
SourceMod Donor
Join Date: Feb 2011
Old 04-23-2011 , 17:36   SQL_PrepareQuery Run Time Error 10
Reply With Quote #1

Error:
Code:
L 04/23/2011 - 09:35:36: [MySQL] Invalid database handle: 0
L 04/23/2011 - 09:35:36: [AMXX] Displaying debug trace (plugin "aps_autosave.amxx")
L 04/23/2011 - 09:35:36: [AMXX] Run time error 10: native error (native "SQL_PrepareQuery")
L 04/23/2011 - 09:35:36: [AMXX]    [0] aps_autosave.sma::client_connect (line 170)
Code:
PHP Code:
public client_connect(id)
{
    
// Check for steam ID pending
    
static steamid[32];
    
get_user_authid(idsteamid31);
    
    
// Then the player doesn't have a steam id, lets make them reconnect
    
if ( equal(steamid"STEAM_ID_PENDING") )
    {
        
client_cmdid"reconnect" );
        
        return 
PLUGIN_HANDLED;
    }

    
g_saps[id] = 0;
    
loaded[id] = 0
    
    
new szQuery[256];

    
format(szQuery255"SELECT * FROM cs_bank WHERE steamid = '%s'"steamid);

    new 
Handle:query SQL_PrepareQueryg_DBConnszQuery );

    if( !
SQL_Executequery ) )
    {
        
server_print("[APS] Connection to the database failed.")

        return 
PLUGIN_HANDLED;
    }
        
    if(
SQL_NumResultsquery ) != 0)
    {
        
LoadUser(id);
        
SQL_FreeHandle(query);
        return 
PLUGIN_HANDLED
    
}
    
    if(
SQL_NumResults(query) == 0)
    {
        
SQL_FreeHandle(query);

        
format(szQuery255"INSERT INTO `cs_bank` (`steamid`, `aps`, `saps`) VALUES ('%s', '0', '0')"steamid);
            
zp_set_user_ammo_packs(id10);
            
g_saps[id] = 5;

        
query SQL_PrepareQuery(g_DBConnszQuery);

        if(!
SQL_Execute(query))
        {
            
server_print("[APS] Database Error at creating an ammo pack field.");
            return 
PLUGIN_HANDLED;
        }

        
SQL_FreeHandle(query);
        return 
PLUGIN_HANDLED
    
}
    
    return 
PLUGIN_HANDLED;

Line 170:
PHP Code:
new Handle:query SQL_PrepareQueryg_DBConnszQuery ); 
Task I am trying to achieve here is to load certain fields from the database. And I do achieve it, but for some reason, get this error from time to time. And I believe it happens when the query doesn't load anything from the query to the variables.

Does anyone know what could this be?
Russianeer is offline
 



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 19:46.


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