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(id, steamid, 31);
// Then the player doesn't have a steam id, lets make them reconnect
if ( equal(steamid, "STEAM_ID_PENDING") )
{
client_cmd( id, "reconnect" );
return PLUGIN_HANDLED;
}
g_saps[id] = 0;
loaded[id] = 0
new szQuery[256];
format(szQuery, 255, "SELECT * FROM cs_bank WHERE steamid = '%s'", steamid);
new Handle:query = SQL_PrepareQuery( g_DBConn, szQuery );
if( !SQL_Execute( query ) )
{
server_print("[APS] Connection to the database failed.")
return PLUGIN_HANDLED;
}
if(SQL_NumResults( query ) != 0)
{
LoadUser(id);
SQL_FreeHandle(query);
return PLUGIN_HANDLED
}
if(SQL_NumResults(query) == 0)
{
SQL_FreeHandle(query);
format(szQuery, 255, "INSERT INTO `cs_bank` (`steamid`, `aps`, `saps`) VALUES ('%s', '0', '0')", steamid);
zp_set_user_ammo_packs(id, 10);
g_saps[id] = 5;
query = SQL_PrepareQuery(g_DBConn, szQuery);
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_PrepareQuery( g_DBConn, szQuery );
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?