MySQL problem - 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 problem (
/showthread.php?tid=623988)
MySQL problem -
IceBilizard - 09.12.2016
Hello guys today i have decided to work on MySQL so i have start to convert my saving system to MySQL but i got some problems with saving i have created a table users and when i try to add more then 5 columns then data not getting saved i am confused please help me.
this code working perfectly and saving data
PHP код:
format(query2 ,sizeof(query2), "INSERT INTO `users` (PN, PS, SC, MN, DT) VALUES ('%s', 'abc', %d, %d, %d)",
playername, GetPlayerScore(playerid), GetPlayerMoney(playerid), deaths[playerid]);
mysql_query(mysql, query2);
if i add 1 more column then its not getting saved.
table structure
Re: MySQL problem -
jlalt - 09.12.2016
it can be your query2 size try increasing it then adding another column.
Re: MySQL problem -
IceBilizard - 09.12.2016
Quote:
Originally Posted by jlalt
it can be your query2 size try increasing it then adding another column.
|
Thanks you man solved my problem
+REP
Re: MySQL problem -
itsCody - 09.12.2016
If you're updating values that are already in the database, you just use..
Just an example
PHP код:
new query2[200];
mysql_format(mysql, query2 , sizeof(query2), "UPDATE `users` SET PS = 'abc', SC = '%d,' MN = '%d', DT = '%d' WHERE PN = '%e'", GetPlayerScore(playerid), GetPlayerMoney(playerid), deaths[playerid], playername);
mysql_query(mysql, query2);
If you don't want to use mysql_format use %q for strings to escape them.
Though many would recommend saving with their database ID, instead of their usernames