SA-MP Forums Archive
Error in SQL syntax - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Server (https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: Error in SQL syntax (/showthread.php?tid=624794)



Error in SQL syntax - GoldenLion - 22.12.2016

Hi, when I try to insert an account's information into the accounts table then I get this error:
Код:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near... <here comes the ip and lastlogin>
When I do that on localhost (Windows) then it works, but when I do it on frag.gs and that CentOS MySQL then it gives me that error. This is what I do in the script:
Код:
mysql_format(g_MySQL, query, sizeof(query), "INSERT INTO `accounts` (`Name`, `Password`, `Salt`, `Email`, `IP`, `LastLogin`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s')", GetName(playerid), PlayerInfo[playerid][pPassword], PlayerInfo[playerid][pSalt], PlayerInfo[playerid][pEmail], PlayerInfo[playerid][pIP], PlayerInfo[playerid][pLastLogin]);
mysql_tquery(g_MySQL, query, "OnQueryFinished", "dd", playerid, QUERY_CREATE_ACCOUNT);
Does it have to do something with frag or I'm doing something wrong?


Re: Error in SQL syntax - Yaa - 22.12.2016

i think you using a old version of MySQL Server ! :P

this one work with +8.0 i think


Re: Error in SQL syntax - GoldenLion - 22.12.2016

No idea. I'm using what frag gives, but the plugin is R41-2 itself.

EDIT: I downloaded R41 and it seems to be working now.


Re: Error in SQL syntax - Private200 - 23.12.2016

Add a "printf("%s", query);" under your MySQL query so you can see the output and understand what's being executed. If you can't find the problem yourself, post it here so we may help you.


Re: Error in SQL syntax - X337 - 23.12.2016

Escape your string, use '%e' instead of '%s'


Re: Error in SQL syntax - Sew_Sumi - 23.12.2016

Yea, frag can't run up to date plugins for "some reason".


Re: Error in SQL syntax - Vince - 23.12.2016

Quote:
Originally Posted by GoldenLion
Посмотреть сообщение
Код:
syntax to use near... <here comes the ip and lastlogin>
Why did you cut out the most important information? To use near ... what?


Re: Error in SQL syntax - BroZeus - 23.12.2016

Make sure string is big enough to hold whole query as I don't see any syntax error in the format line.

And as Vince said why did you hide the part after near, show it to us we ain't gonna ddos your ip.


Re: Error in SQL syntax - GoldenLion - 23.12.2016

OK, here's the whole error:
Код:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'none', '90.190.102.196', '22/12/2016, 16:23')'
"none" is the email and that date is the last login.

Quote:
Originally Posted by X337
Посмотреть сообщение
Escape your string, use '%e' instead of '%s'
I think there is no need to escape strings at this case.


Re: Error in SQL syntax - Konstantinos - 23.12.2016

If the last character of the (random) salt is apostrophe will give the exact same error and escaping the string is the only way to fix this.