Raised This Month: $51 Target: $400
 12% 

Error fetching data from field 1


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LambdaLambda
AlliedModders Donor
Join Date: Oct 2010
Location: London
Old 10-15-2013 , 12:55   Error fetching data from field 1
Reply With Quote #1

Hey,

hope it's goint to be my last question. What's wrong with this piece of code?

http://pastebin.com/XamZLmGE
Code:
DajPkt(ilepkt)
{
	new String:sqlstring[255];
	Format(sqlstring, sizeof(sqlstring), "SELECT steamid FROM gocs_pkt WHERE ingame = '1'")
	SQL_LockDatabase(dbcon);     
	new Handle:sql3 = SQL_Query(dbcon, sqlstring);
	while(SQL_FetchRow(sql3))
	{
		SQL_UnlockDatabase(dbcon);
		new String:sid[50];
		SQL_FetchString(sql3, 1, sid, sizeof(sid));
		CloseHandle(sql3);

		SQL_UnlockDatabase(dbcon);

		Format(sqlstring, sizeof(sqlstring), "UPDATE pfields_content SET eco_points = eco_points + '%i' AND eco_worth = eco_worth + '%i' WHERE %s = '%s'", ilepkt, ilepkt, sidpole, sid);
		SQL_Query(dbconipb, sqlstring);
	}
	
	CloseHandle(sql3);

	SQL_UnlockDatabase(dbcon);
}
It compiles well, but gives me feedback:
Quote:
L 0/15/2013 - 17:53:48:1 [SM] Native "SQL_FetchString" reported: Error fetching data from field 1
LambdaLambda is offline
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
LambdaLambda
AlliedModders Donor
Join Date: Oct 2010
Location: London
Old 10-15-2013 , 14:21   Re: Error fetching data from field 1
Reply With Quote #3

Thank you, it works! But I've got weird problem with formating the last querry. When I update eco_points and eco_worth seperatly, then it works as it should, but when I try to make it in one querry (like above) then nothing happens.
LambdaLambda is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 10-15-2013 , 14:44   Re: Error fetching data from field 1
Reply With Quote #4

*edited my post above.
Leonardo is offline
LambdaLambda
AlliedModders Donor
Join Date: Oct 2010
Location: London
Old 10-15-2013 , 16:17   Re: Error fetching data from field 1
Reply With Quote #5

Thanks ;)
LambdaLambda is offline
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 10:40.


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