Error in SQL syntax
#1

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?
Reply
#2

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

this one work with +8.0 i think
Reply
#3

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.
Reply
#4

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.
Reply
#5

Escape your string, use '%e' instead of '%s'
Reply
#6

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

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?
Reply
#8

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.
Reply
#9

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.
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)