Mysql Help !!!
#1




Код:
stock LoadMailboxes()
{
	printf("[LoadMailboxes] Loading data from database...");
	mysql_function_query(MainPipeline, "SELECT * FROM `mailboxes`", true, "OnLoadMailboxes", "");
}

forward OnLoadMailboxes();
public OnLoadMailboxes()
{
	new string[512], i;
	new rows, fields;
	cache_get_data(rows, fields, MainPipeline);
	while(i<rows)
	{
	    for(new field;field<fields;field++)
	    {
 		    cache_get_row(i, field, string, MainPipeline);
			switch(field)
			{
			    case 1: MailBoxes[i][mbVW] = strval(string);
				case 2: MailBoxes[i][mbInt] = strval(string);
				case 3: MailBoxes[i][mbModel] = strval(string);
				case 4: MailBoxes[i][mbPosX] = floatstr(string);
				case 5: MailBoxes[i][mbPosY] = floatstr(string);
				case 6: MailBoxes[i][mbPosZ] = floatstr(string);
				case 7: MailBoxes[i][mbAngle] = floatstr(string);
			}
		}
		RenderStreetMailbox(i);
  		i++;
 	}
	if(i > 0) printf("[LoadMailboxes] %d mailboxes rehashed/loaded.", i);
	else printf("[LoadMailboxes] Failed to load any mailboxes.");
	return 1;
}

stock SaveMailbox(id)
{
	new string[512];

	format(string, sizeof(string), "UPDATE `mailboxes` SET \
		`VW`=%d, \
		`Int`=%d, \
		`Model`=%d, \
		`PosX`=%f, \
		`PosY`=%f, \
		`PosZ`=%f, \
		`Angle`=%f WHERE `id`=%d",
		MailBoxes[id][mbVW],
		MailBoxes[id][mbInt],
		MailBoxes[id][mbModel],
		MailBoxes[id][mbPosX],
		MailBoxes[id][mbPosY],
		MailBoxes[id][mbPosZ],
		MailBoxes[id][mbAngle],
		id+1
	); // Array starts from zero, MySQL starts at 1 (this is why we are adding one).

	mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
}
Reply
#2

The fix is quite obvious if you'd just look what the error actually says.
Код:
right syntax to use near '`Paper`
Then examine the query and search for Paper. Then conclude that you forgot a comma.

By the way, you should read my tutorial on database normalization.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)