MySql help - 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 (
/showthread.php?tid=634684)
MySql help -
akib - 24.05.2017
Hi, I am using latest mysql script.
How i can store 2 data at once
example:
Код:
new query[70];
mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `owner` = %d,`health` = %f WHERE `id` = %d LIMIT 1", Player[playerid][Owner],Player[playerid][Health], Player[playerid][ID]);
mysql_tquery(g_SQL, query);
i tried this code not working
but when i do single it saves
Код:
new query[70];
mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `owner` = %d WHERE `id` = %d LIMIT 1", Player[playerid][Owner], Player[playerid][ID]);
mysql_tquery(g_SQL, query);
Re: MySql help -
iLearner - 24.05.2017
PHP код:
new query[70];
mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `owner` = %d,`health` = %d WHERE `id` = %d LIMIT 1", Player[playerid][Owner],Player[playerid][Health], Player[playerid][ID]);
mysql_tquery(g_SQL, query, "", "");
Re: MySql help -
akib - 25.05.2017
Quote:
Originally Posted by iLearner
PHP код:
new query[70];
mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `owner` = %d,`health` = %d WHERE `id` = %d LIMIT 1", Player[playerid][Owner],Player[playerid][Health], Player[playerid][ID]);
mysql_tquery(g_SQL, query, "", "");
|
still not saving data :/
Re: MySql help -
Lbaker - 25.05.2017
Do you have any error in MySQL Log?
Re: MySql help -
akib - 25.05.2017
Quote:
Originally Posted by Lbaker
Do you have any error in MySQL Log?
|
no it is empty.....
u mean D:\GTA San Andreas\Server\logs\errors.log?
it is empty
Re: MySql help -
Cadilab - 25.05.2017
maybe your health is the same or you don't have health column ?
plus the lenght of your first query is 71 chars and you have 75+ with health and your string is only 70.
Re: MySql help -
Burridge - 25.05.2017
Quote:
Originally Posted by iLearner
PHP код:
new query[70];
mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `owner` = %d,`health` = %d WHERE `id` = %d LIMIT 1", Player[playerid][Owner],Player[playerid][Health], Player[playerid][ID]);
mysql_tquery(g_SQL, query, "", "");
|
Health is NOT an integer! Also mysql_tquery doesn't need the "" if those parameters are empty as they are optional. See:
https://sampwiki.blast.hk/wiki/MySQL/R40#mysql_tquery
It's odd to me that there are no errors from this if it isn't saving...
Код:
new query[80];
mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `owner` = %d,`health` = %.1f WHERE `id` = %d LIMIT 1", Player[playerid][Owner], Player[playerid][Health], Player[playerid][ID]);
mysql_tquery(g_SQL, query);
Your Player[playerid][Health] variable is set as a float when declared, right? Also are you getting the player's health and storing it to that variable prior to this query being executed?