Help mysql crashing
#1

Why this code is crashing my server:

Код:
stock AddLabelToFile(LabelID, LabelInfo[], color, Float:LX, Float:LY, Float:LZ)
{
	new Query[200];
	format(Query, sizeof(Query), "INSERT INTO `labels` (posx, posy, posz, color, labeltext) VALUES(%f, %f, %f, %d, '%s')", LX, LY, LZ, color, LabelInfo);
	mysql_function_query(dbHandle, Query, true, "OnLabelInsert", "is[128]dfff", LabelID, LabelInfo, color, LX, LY, LZ);
	return 1;
}

forward OnLabelInsert(LabelID, LabelInfo, color, LX, LY, LZ);
public OnLabelInsert(LabelID, LabelInfo, color, LX, LY, LZ)
{
	LabelsInfo[LabelID][tID] = mysql_insert_id();
	LabelsInfo[LabelID][LabelX] = LX;
	LabelsInfo[LabelID][LabelY] = LY;
	LabelsInfo[LabelID][LabelZ] = LZ;
	LabelsInfo[LabelID][LColor] = color;
	LabelsInfo[LabelID][LInfo] = LabelInfo;
	LabelsInfo[LabelID][LID] = CreateDynamic3DTextLabel(LabelsInfo[LabelID][LInfo], LabelsInfo[LabelID][LColor], LabelsInfo[LabelID][LabelX], LabelsInfo[LabelID][LabelY], LabelsInfo[LabelID][LabelZ], 15.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0);
	return 1;
}
Reply
#2

The format specifiers for the mysql plugin are not the same as those for sscanf. So a singular 's' without size will suffice. Next, if you want to pass a string to a function then that parameter must be declared as such in the function header. Same applies to floating point values.

pawn Код:
public OnLabelInsert(LabelID, LabelInfo[], color, Float:LX, Float:LY, Float:LZ)
I am surprised that you even ran this on your server, even though the compiler should have given you a ton of warnings (tag mismatch and such).
Reply
#3

thanks man, it works now
mysql is so fun, i've made tons of systems, doors, pickups ETC..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)