View Single Post
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 10-15-2013 , 13:05   Re: Error fetching data from field 1
Reply With Quote #2

Code:
DajPkt(ilepkt)
{
	new String:sqlstring[255];
	Format(sqlstring, sizeof(sqlstring), "SELECT steamid FROM gocs_pkt WHERE ingame <> 0")
	SQL_LockDatabase(dbcon);     
	new Handle:sql3 = SQL_Query(dbcon, sqlstring);
	if( sql3 != INVALID_HANDLE ) // add this (with curly brackets)
	{
		while(SQL_FetchRow(sql3))
		{
			SQL_UnlockDatabase(dbcon);
			new String:sid[50];
			SQL_FetchString(sql3, 0, sid, sizeof(sid)); // fix
			
			//CloseHandle(sql3); // remove this
			//SQL_UnlockDatabase(dbcon); // and this

			Format(sqlstring, sizeof(sqlstring), "UPDATE pfields_content SET eco_points = eco_points + %d, eco_worth = eco_worth + %d WHERE %s = '%s'", ilepkt, ilepkt, sidpole, sid);
			SQL_TQuery(dbconipb, sqlstring); // fix
		}
		SQL_UnlockDatabase(dbcon); // moved up
		CloseHandle(sql3); // moved down
	}
	else
		SQL_UnlockDatabase(dbcon); // new!!
}
but it looks pretty bad.

Last edited by Leonardo; 10-15-2013 at 14:44.
Leonardo is offline