SA-MP Forums Archive
MySQL help - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: MySQL help (/showthread.php?tid=265132)



MySQL help - ScottCFR - 29.06.2011

I've been working on a house system, and I've made a command to add houses while in game. But, I seem to have messed something up. Here's my command:
Код:
COMMAND:createhouse(playerid, params[])
{
	new query[65],Float:x,Float:y,Float:z,name[64],cost;
    if(!sscanf(params, "si", name, cost))
    {
        GetPlayerPos(playerid, x, y, z);
		format(query,sizeof(query),"INSERT INTO [REMOVED] (Name, Cost, PosX, PosY, PosZ) VALUES ('%s', '%d', '%s', '%s', '%s')",name,cost,x,y,z);
		mysql_query(query);
		SendCommandToAdmins(playerid, 4, "/addhouse");
    }
	return 1;
}
Error:
Код:
[16:05:01] CMySQLHandler::Query(INSERT INTO [REMOVED] (Name, Cost, PosX, PosY, PosZ) VALUES ('Visag) - An error has occured. (Error ID: 1064, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''Visag' at line 1)
[16:05:09] >> mysql_ping( Connection handle: 1 )



AW: MySQL help - Blowfish - 29.06.2011

Make sure there is no single quote (') in your strings.


Re: MySQL help - [L3th4l] - 29.06.2011

Increase the size of "query" and since when are floats strings?


AW: MySQL help - Blowfish - 29.06.2011

Nvm, was too slow.
L3tha4 brought it to the point.


Re: MySQL help - ScottCFR - 29.06.2011

Quote:
Originally Posted by [L3th4l]
Посмотреть сообщение
Increase the size of "query" and since when are floats strings?
Well, when I noticed something weird when I would format them into floats. So, if I set them to strings, then convert the string to a float while loading it works fine.