MYSQL query error
#1

I can't understand why i get these errors:

pawn Код:
[22:01:03] CMySQLHandler::Query(INSERT INTO `privateveh` (`vID`, `vModel`, `vColor1`, `vColor2`, `vPrice`, `vOwner`, `vPosX`, `vPosY`, `vPosZ`, `vPosA`) VALUES (1, 602, 96, 229, 30000, John_Kayle, -1922.270019, 303.734588, 40.732200, 270.628601)) - An error has occured. (Error ID: 1054, Unknown column 'John_Kayle' in 'field list')
[22:01:03] >> mysql_query( Connection handle: 1 )
I get it when i use:
pawn Код:
new name[MAX_PLAYER_NAME];
                    GetPlayerName(playerid, name, sizeof(name));

                    strmid(vInfo[Created][vOwner], name, 0, 128, 128);

                    format(Query, sizeof(Query), "INSERT INTO `privateveh` (`vID`, `vModel`, `vColor1`, `vColor2`, `vPrice`, `vOwner`, `vPosX`, `vPosY`, `vPosZ`, `vPosA`) VALUES (%d, %d, %d, %d, %d, %s, %f, %f, %f, %f)",
                    Created,
                    ivModel,
                    ivColors[0],
                    ivColors[1],
                    ivPrice,
                    name,
                    Pos[0],
                    Pos[1],
                    Pos[2],
                    Pos[3]);
                    mysql_query(Query);
Reply
#2

It's an SQL syntax error, John_Kayle is a string, therefore it must be wrapped in quotes in the query, like so:

pawn Код:
"INSERT INTO `privateveh` (`vID`, `vModel`, `vColor1`, `vColor2`, `vPrice`, `vOwner`, `vPosX`, `vPosY`, `vPosZ`, `vPosA`) VALUES (%d, %d, %d, %d, %d, '%s', %f, %f, %f, %f)
Reply
#3

Thank you very much
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)