SA-MP Forums Archive
MySQL syntax 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)
+--- Thread: MySQL syntax error (/showthread.php?tid=657469)



MySQL syntax error - KinderClans - 07.08.2018

I'm getting mysql syntax error (You have a SQL error in your syntax) here:

pawn Код:
mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `LastLogin` = %s, `Kills` = %d, `Deaths` = %d, `Score` = %i, `Money` = %i, `Level` = %d, `WantedLevel` = %d, `Skin` = %d, `PlayerTeam` = %d, `PlayerGender` = %d, `PlayingHours` = %d, `PlayingMinutes` = %d, `FirstSpawn` = %d WHERE `id` = %d LIMIT 1",
What's wrong?


Re: MySQL syntax error - zPain - 07.08.2018

Код:
LastLogin ='%s'
Also there's no need for a LIMIT clause.


Re: MySQL syntax error - KinderClans - 07.08.2018

I never used ' ' for %s or %d values and always worked in that way.

I edited before the query to add new data to update and got this sql error.


Re: MySQL syntax error - zPain - 07.08.2018

Well you should use it for %s.


Re: MySQL syntax error - zPain - 07.08.2018

%s and %e.


Re: MySQL syntax error - KinderClans - 07.08.2018

Ok now saving works. Getting now sql syntax error here:

pawn Код:
new query[128];
    format(query, sizeof(query), "UPDATE `players` SET `RegisterDate` = '%s', `RegisterIP` = '%s', `LastLogin` = '%s' WHERE `username` = '%s'", ReturnDate(), ReturnPlayerIp(playerid), ReturnDate(), Player[playerid][Name]);
    mysql_tquery(g_SQL, query);
RegisterDate and RegisterIP doesn't get saved.


Re: MySQL syntax error - zPain - 07.08.2018

128 doesn't seem to be enough for that query.


Re: MySQL syntax error - KinderClans - 07.08.2018

Yeah you were right, now works. Thank you.

If you could help me with this too: https://sampforum.blast.hk/showthread.php?pid=4043064#pid4043064

I'll appreciate it much since i'm struggling with that from days.

Thanks.