Attachments MYSQL
#1

Код:
    new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, MAX_PLAYER_NAME);
	new query[130];
    mysql_format(SQLHandle, query, sizeof(query), "SELECT * FROM attachments WHERE name='%e' AND indx='%d'", name, index);
	mysql_tquery(SQLHandle, query, "", "");
	
	new querys[1024];
	new rows, fields;
	cache_get_data(rows, fields, SQLHandle);
	if(rows)
	{
	    mysql_format(SQLHandle, querys, sizeof(querys), "UPDATE `attachments` SET model = %d, bone = %d, setX = %f, setY = %f, setZ = %f, rotX = %f, rotY = %f, rotZ = %f, sclX = %f, sclY = %f, sclZ = %f, WHERE `name` = %s AND `indx` = %d",
		modelid,boneid,fOffsetX,fOffsetY,fOffsetZ,fRotX,fRotY,fRotZ,fScaleX,fScaleY,fScaleZ,name,index);
		mysql_tquery(SQLHandle, querys, "", "");
	}else{
     	mysql_format(SQLHandle, querys, sizeof(querys), "INSERT INTO `attachments`(`name`, `indx`, `model`, `bone`, `setX`, `setY`, `setZ`, `rotX`, `rotY`, `rotZ`, `sclX`, `sclY`, `sclZ`) VALUES (%e,%d,%d,%d,%f,%f,%f,%f,%f,%f,%f,%f,%f)",
		name,index,modelid,boneid,fOffsetX,fOffsetY,fOffsetZ,fRotX,fRotY,fRotZ,fScaleX,fScaleY,fScaleZ);
		mysql_tquery(SQLHandle, querys, "", "");
	}
INSERT INTO do not want to be entered into the database
Reply
#2

You need to escape string with single quotes :

Change :
Код:
mysql_format(SQLHandle, querys, sizeof(querys), "INSERT INTO `attachments`(`name`, `indx`, `model`, `bone`, `setX`, `setY`, `setZ`, `rotX`, `rotY`, `rotZ`, `sclX`, `sclY`, `sclZ`) VALUES (%e,%d,%d,%d,%f,%f,%f,%f,%f,%f,%f,%f,%f)",
To :
Код:
mysql_format(SQLHandle, querys, sizeof(querys), "INSERT INTO `attachments`(`name`, `indx`, `model`, `bone`, `setX`, `setY`, `setZ`, `rotX`, `rotY`, `rotZ`, `sclX`, `sclY`, `sclZ`) VALUES ('%e',%d,%d,%d,%f,%f,%f,%f,%f,%f,%f,%f,%f)",
Reply
#3

here fs : http://pastebin.com/KJz5GkWw
*Player Attachments system by Excel
I just change it to mysql,
something go wrong
when stored, the position is not exactly as edited. and when you back edit it will INSERT to the database is not UPDATE
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)