SA-MP Forums Archive
mysql help [+REP] - 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)
+--- Thread: mysql help [+REP] (/showthread.php?tid=575086)



mysql help [+REP] - simo0000 - 23.05.2015

i'm working in my own mysql car ownership system
and i got a error
pawn Код:
21:41:58] [DEBUG] mysql_format - connection: 1, len: 200, format: "INSERT INTO `pvehicles` (`vOwner`, `vModel`, `vColor1`, `vColor2`, `vX`, `vY`, `vZ`, `vA`) VALUES(%s, %i, %i, %i, %f, %f, %f, %f..."
[21:41:58] [DEBUG] mysql_query - connection: 1, query: "INSERT INTO `pvehicles` (`vOwner`, `vModel`, `vColor1`, `vColor2", use_cache: true
[21:41:58] [DEBUG] CMySQLQuery::CMySQLQuery() - constructor called
[21:41:58] [DEBUG] CMySQLQuery::Execute[()] - starting query execution
[21:41:58] [ERROR] CMySQLQuery::Execute[()] - (error #1054) Unknown column 'Marco_Smith' in 'field list'
here is the problem
pawn Код:
mysql_format(mysql, string, sizeof(string), "SELECT `vOwner` FROM `pvehicles` WHERE `vOwner` = '%s'", name);
mysql_query(mysql, string);
plz help

sorry for my bad english


Re: mysql help [+REP] - Konstantinos - 23.05.2015

It's not in that query but in INSERT instead.

You used %s but you need to use '%s' or even better '%e' (so it escapes strings to avoid SQL Injection).

pawn Код:
INSERT INTO `pvehicles` (`vOwner`, `vModel`, `vColor1`, `vColor2`, `vX`, `vY`, `vZ`, `vA`) VALUES ('%e', %i, %i, %i, %f, %f, %f, %f)



Re : Re: mysql help [+REP] - simo0000 - 23.05.2015

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
It's not in that query but in INSERT instead.

You used %s but you need to use '%s' or even better '%e' (so it escapes strings to avoid SQL Injection).

pawn Код:
INSERT INTO `pvehicles` (`vOwner`, `vModel`, `vColor1`, `vColor2`, `vX`, `vY`, `vZ`, `vA`) VALUES ('%e', %i, %i, %i, %f, %f, %f, %f)
thnx mate it's works repped