SA-MP Forums Archive
Help Pls : Lost connection to MySQL server during query - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help Pls : Lost connection to MySQL server during query (/showthread.php?tid=487234)



Help Pls : Lost connection to MySQL server during query - bigtigerbeee - 12.01.2014

Code:
20:50:08] errorid: 2013 | error: Lost connection to MySQL server during query | resultid: -1 | extraid: -1 | callback: NULL | query: UPDATE groups SET groupName = 'Government', groupHQExteriorPosX = '1479.785278', groupHQExteriorPosY = '-1752.154663', groupHQExteriorPosZ = '13.546875', groupHQInteriorID = '3', groupHQLockStatus = '0', groupHQInteriorPosX = '389.451202', groupHQInteriorPosY = '173.810348', groupHQInteriorPosZ = '1008.382812', groupSafeMoney = '35570688', groupSafeMats = '0', groupSafeIron = '1', groupSafeWood = '1', groupSafeSeed = '1', groupSafeWeed = '1', groupMOTD = 'Leader-Lamont will be inactive till Monday have fun and RP till I am back.', groupRankName0 = '(null)', groupRankName1 = 'บอดี้การ์ด', groupRankName2 = 'รัฐมนตรีว่าการกระทรวงการคลัง', groupRankName3 = 'รัฐมนตรีว่าการกระทรวงยุติธรรม', groupRankName4 = 'รัฐมนตรีว่าการกระทรวงกลาโหม', groupRankName5 = 'ผู้ว่าการรัฐบาล', groupRankName6 = 'ประธานาธิบดี', groupRankName7 = '(null)', groupRankName8 = '(null)', groupRankName9 = '(null)', groupRankName10 = '(null)', groupRankName11 = '(null)', groupRankName12 = '(null)', groupRankName13 = 'ผู้ว่าการรัฐบาล', groupRankName14 = 'ประธานาธิบดี', groupSafePosX = '1911.246459', groupSafePosY = '-1759.860351', groupSafePosZ = '15.339500', groupType = '2' WHERE groupID = '4'
Code:
stock saveGroup(const id) {
	if(strlen(groupVariables[id][gGroupName]) >= 1) {
		format(szLargeString, sizeof(szLargeString), "UPDATE groups SET groupName = '%s', groupHQExteriorPosX = '%f', groupHQExteriorPosY = '%f', groupHQExteriorPosZ = '%f'", groupVariables[id][gGroupName], groupVariables[id][gGroupExteriorPos][0], groupVariables[id][gGroupExteriorPos][1], groupVariables[id][gGroupExteriorPos][2]);
		format(szLargeString, sizeof(szLargeString), "%s, groupHQInteriorID = '%d', groupHQLockStatus = '%d', groupHQInteriorPosX = '%f', groupHQInteriorPosY = '%f', groupHQInteriorPosZ = '%f', groupSafeMoney = '%d', groupSafeMats = '%d', groupSafeIron = '%d', groupSafeWood = '%d', groupSafeSeed = '%d', groupSafeWeed = '%d', groupMOTD = '%s'", szLargeString, groupVariables[id][gGroupHQInteriorID],
		groupVariables[id][gGroupHQLockStatus], groupVariables[id][gGroupInteriorPos][0], groupVariables[id][gGroupInteriorPos][1], groupVariables[id][gGroupInteriorPos][2], groupVariables[id][gSafe][0], groupVariables[id][gSafe][1], groupVariables[id][gSafe][2], groupVariables[id][gSafe][3], groupVariables[id][gSafe][4], groupVariables[id][gSafe][5], groupVariables[id][gGroupMOTD]);
		format(szLargeString, sizeof(szLargeString), "%s, groupRankName0 = '%s', groupRankName1 = '%s', groupRankName2 = '%s', groupRankName3 = '%s', groupRankName4 = '%s', groupRankName5 = '%s', groupRankName6 = '%s', groupRankName7 = '%s', groupRankName8 = '%s', groupRankName9 = '%s', groupRankName10 = '%s', groupRankName11 = '%s', groupRankName12 = '%s', groupRankName13 = '%s', groupRankName14 = '%s'", szLargeString,
		groupVariables[id][gGroupRankName0],groupVariables[id][gGroupRankName1], groupVariables[id][gGroupRankName2], groupVariables[id][gGroupRankName3], groupVariables[id][gGroupRankName4], groupVariables[id][gGroupRankName5], groupVariables[id][gGroupRankName6],groupVariables[id][gGroupRankName7],groupVariables[id][gGroupRankName8], groupVariables[id][gGroupRankName9], groupVariables[id][gGroupRankName10], groupVariables[id][gGroupRankName11],
		groupVariables[id][gGroupRankName12], groupVariables[id][gGroupRankName13], groupVariables[id][gGroupRankName14]);
		format(szLargeString, sizeof(szLargeString), "%s, groupSafePosX = '%f', groupSafePosY = '%f', groupSafePosZ = '%f', groupType = '%d' WHERE groupID = '%d'", szLargeString, groupVariables[id][gSafePos][0], groupVariables[id][gSafePos][1], groupVariables[id][gSafePos][2], groupVariables[id][gGroupType], id);
  		mysql_query(szLargeString);
	}
	else {
		return 0;
	}

	return 1;

}



Respuesta: Help Pls : Lost connection to MySQL server during query - Stront - 12.01.2014

Don't make such big query. Form smally querys with the same information and send the request in many querys instead of a big query with all the information, because it causes problems to the mysql connection due to the such big packet of information.


Re: Help Pls : Lost connection to MySQL server during query - bigtigerbeee - 12.01.2014

change szLargeString size ?


Respuesta: Help Pls : Lost connection to MySQL server during query - Stront - 12.01.2014

Hmm. You must do the same thing you've done in parts. For understanding.

You have to cut down that enormous string in pieces. For example.

format(query, sizeof(query), "UPDATE table SET X = %d Y = %d Z = %d");
mysql_query(query);
format(query, sizeof(query), "UPDATE table SET A = %d B = %d C = %d");
mysql_query(query);
format(query, sizeof(query), "UPDATE table SET J = %d K = %d L = %d");
mysql_query(query);

With your variable string and your variables inside. You understood?


Re: Help Pls : Lost connection to MySQL server during query - bigtigerbeee - 12.01.2014

Thank