MySQL - Saving a String [HELP] -
Ciarannn - 04.05.2015
Код:
mysql_format(mysql, query, sizeof(query), "UPDATE `users` SET `vReg`=%s, `vVReg`=%s, `vVVReg`=%s, `vVVVReg`=%s WHERE `ID`=%d",
PlayerInfo[playerid][vReg], PlayerInfo[playerid][vVReg], PlayerInfo[playerid][vVVReg], PlayerInfo[playerid][vVVVReg], PlayerInfo[playerid][ID]);
mysql_tquery(mysql, query);
This is my code for saving four strings but the mysql_log returns an Error:
Код:
[17:42:59] [ERROR] CMySQLQuery::Execute[] - (error #1054) Unknown column '' in 'field list'
Am I doing it wrong? Or?
Re: MySQL - Saving a String [HELP] -
iPrivate - 04.05.2015
pawn Код:
mysql_format(mysql, query, sizeof(query), "UPDATE users SET `vReg`='%s', vVReg='%s', vVVReg='%s', vVVVReg='%s' WHERE ID='%d'",
PlayerInfo[playerid][vReg], PlayerInfo[playerid][vVReg], PlayerInfo[playerid][vVVReg], PlayerInfo[playerid][vVVVReg], PlayerInfo[playerid][ID]);
mysql_tquery(mysql, query);
That should do the work.
Re: MySQL - Saving a String [HELP] -
Ciarannn - 19.05.2015
Sorry for bringing this thread back up but I never got back to it and when I did it still doesn't work. I know the problem but I don't know a solution.
So if I do this:
Код:
mysql_format(mysql, query, sizeof(query), "UPDATE `users` SET vReg=`%s` WHERE `ID`=%d", PlayerInfo[playerid][vReg], PlayerInfo[playerid][ID]);
mysql_tquery(mysql, query);
It thinks that the string is a column in my database and returns the error "Unknown column" followed by the string.
If I do this:
Код:
mysql_format(mysql, query, sizeof(query), "UPDATE `users` SET `vReg`=%s WHERE `ID`=%d", PlayerInfo[playerid][vReg], PlayerInfo[playerid][ID]);
mysql_tquery(mysql, query);
It also doesn't work because the string has spaces in it which would return this in an fprint:
Код:
UPDATE `users` SET `vReg`=15 LV 1809 WHERE `25`=%d
If I do this:
Код:
mysql_format(mysql, query, sizeof(query), "UPDATE `users` SET `vReg`=`%s` WHERE `ID`=%d", PlayerInfo[playerid][vReg], PlayerInfo[playerid][ID]);
mysql_tquery(mysql, query);
It still thinks the string is a column.
How do I resolve this?
Re: MySQL - Saving a String [HELP] -
Vince - 19.05.2015
There is a difference between ` (backtick) and ' (quote). The latter one must be used to enclose strings. Avoid using backticks if you can.
Re: MySQL - Saving a String [HELP] -
PowerPC603 - 19.05.2015
PHP код:
mysql_format(mysql, query, sizeof(query), "UPDATE `users` SET `vReg`='%s' WHERE `ID`='%d'", PlayerInfo[playerid][vReg], PlayerInfo[playerid][ID]);
For table-names and column-names, use ` (it's not even required and can be left out)
For fields, use '
Re: MySQL - Saving a String [HELP] -
Ciarannn - 19.05.2015
Quote:
Originally Posted by Vince
There is a difference between ` (backtick) and ' (quote). The latter one must be used to enclose strings. Avoid using backticks if you can.
|
English is my first language, I've been speaking it for sixteen years and no once have I heard the word latter. Had to ****** it lol
Anyways, thank you. It worked. I've been stuck with that problem for ages.
Re: MySQL - Saving a String [HELP] -
Ciarannn - 19.05.2015
Quote:
Originally Posted by PowerPC603
PHP код:
mysql_format(mysql, query, sizeof(query), "UPDATE `users` SET `vReg`='%s' WHERE `ID`='%d'", PlayerInfo[playerid][vReg], PlayerInfo[playerid][ID]);
For table-names and column-names, use ` (it's not even required and can be left out)
For fields, use '
|
Thank you also.