MySQL help
#1

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 )
Reply
#2

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

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

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

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)