MySQL Insert issue.
#1

I haven't really had this much trouble with SQL, and im completely stumped.

pawn Код:
public create_tspawn(playerid,String[])
{
    new Float:X, Float:Y, Float:Z, Float:A,Query[280];
    GetPlayerPos(playerid, X, Y, Z);
    GetPlayerFacingAngle(playerid, A);
    new Team = pInfo[playerid][pTeam];
    new Int = GetPlayerInterior(playerid);
    new VW = GetPlayerVirtualWorld(playerid);
    new Skin = GetPlayerSkin(playerid);
   
    format(Query, sizeof(Query), "INSERT INTO teamspawn (Name, PosX, PosY, PosZ, PosA, Team, Int, VW, Skin) VALUES('%s', %f, %f, %f, %f,%d,%d,%d,%d)", String, X,Y,Z,A,Team, Int, VW, Skin);
    mysql_query(Query);
    return 1;
}
Код:
[00:58:27] CMySQLHandler::Query(INSERT INTO teamspawn (Name, PosX, PosY, PosZ, PosA, Team, Int, VW, Skin) VALUES('hi', 1958.378295, 1343.157226, 15.374607, 269.142486,2,0,0,0)) - 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 'Int, VW, Skin) VALUES('hi', 1958.378295, 1343.157226, 15.374607, 269.142486,2,0,' at line 1)
Whats up?
Reply
#2

Looks like the query is not long enough to handle all the data since everything else looks OK to me.
Try increasing the size of the string.
Reply
#3

Increased it,

Got the following:

Код:
[01:17:19] CMySQLHandler::Query(INSERT INTO teamspawn (Name, PosX, PosY, PosZ, PosA, Team, Int, VW, Skin) VALUES('LSPD1', 244.366989, 69.190086, 1003.640625, 204.908523,2,6,24,280)) - 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 'Int, VW, Skin) VALUES('LSPD1', 244.366989, 69.190086, 1003.640625, 204.908523,2,' at line 1)
Has to be something else.
Reply
#4

You could always try loading up phpmyadmin and testing your query on there. Then it'll tell you exactly what wrong eith your sql syntax. Make sure you have single quotes around all string variables in the sql too
Reply
#5

Int is a MySQL reserved word and therefore cannot be used as a field name. See here: http://dev.mysql.com/doc/refman/5.5/...ved-words.html
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)