SA-MP Forums Archive
MYSQL query error - 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 query error (/showthread.php?tid=225495)



MYSQL query error - ajwar - 13.02.2011

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);



Re: MYSQL query error - JaTochNietDan - 13.02.2011

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)



Re: MYSQL query error - ajwar - 13.02.2011

Thank you very much