Mysql SavePlayer(playerid) error!
#1

Hello,
I've been working on a Mysql login/register system today. Everything is working except for the SavePlayer stock.

Heres the enum:

pawn Код:
enum pInfo
{
    Username[25],
    Password[50],
    PlayerIP[19],
    Score[9]
}

new PlayerInfo[MAX_PLAYERS][pInfo];
Now here's the Stock:

pawn Код:
stock SaveUser(playerid)
{
    new Query[400]; format(Query, sizeof(Query), "UPDATE `names` (Username, Password, PlayerIP, Score) VALUES('%s', '%s', '%s', 's')", GetName(playerid), PlayerInfo[playerid][Password], GetIp(playerid), PlayerInfo[playerid][Score]);
    mysql_query(Query);
    print(Query);
}
And heres the Server_log.txt

Quote:

[12:55:35] [MySQL] Error (0): Failed to exeute query. 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 '(Username, Password, PlayerIP, Score) VALUES('Georgelopez1', '', '255.255.255.25' at line 1.
[12:55:35] UPDATE `names` (Username, Password, PlayerIP, Score) VALUES('Georgelopez1', '', '255.255.255.255', 's')
[12:55:35] [part] Georgelopez1 has left the server (0:1)

Thanks in advance.

P.S. I have changed the UPDATE to INSERT and still no results....

Oh and I'm using StrickenKids plugin.
Reply
#2

Your syntax is wrong. http://www.w3schools.com/php/php_mysql_update.asp
Reply
#3

Could you tell me what is wrong? I have seen 3 different ways to do this, and each time I try its wrong.
Reply
#4

Код:
format(Query, sizeof(Query), "UPDATE `names` SET (Username, Password, PlayerIP, Score) VALUES('%s', '%s', '%s', '%d')", GetName(playerid), PlayerInfo[playerid][Password], GetIp(playerid), PlayerInfo[playerid][Score]);
EDIT: I didn't even check the score part, loled. ( I just copied off his code ) Edited.
Reply
#5

Since when score is a string? It's always numeric! Change it and set inside just %d at the Score column.
Reply
#6

mysql_log
Quote:

[Sun May 1 15:57:40 2011] Error (0): Failed to exeute query. 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 '(Username, Password, PlayerIP, Score) VALUES('Georgelopez1', '', '255.255.255.25' at line 1.

Server_log
Quote:

[15:57:40] [MySQL] Error (0): Failed to exeute query. 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 '(Username, Password, PlayerIP, Score) VALUES('Georgelopez1', '', '255.255.255.25' at line 1.
[15:57:40] UPDATE `names` SET (Username, Password, PlayerIP, Score) VALUES('Georgelopez1', '', '255.255.255.255', '1')

Reply
#7

Ok so heres my stock now:


pawn Код:
stock SaveUser(playerid)
{
    new Query[400];
    format(Query, sizeof(Query), "INSERT INTO `names` WHERE `Score` = %d",
    GetPlayerScore(playerid));
    mysql_query(Query);
    print(Query);
}
And here's the error:

Quote:

[09:01:43] [MySQL] Error (0): Failed to exeute query. 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 'WHERE `Score` = 10' at line 1.
[09:01:43] INSERT INTO `names` WHERE `Score` = 10
[09:01:43] [part] Georgelopez1 has left the server (0:1)

Reply
#8

pawn Код:
stock SaveUser(playerid)
{
    new Query[400];
    format(Query, sizeof(Query), "UPDATE `names` SET `Username` = '%s', `Password` = '%s', `PlayerIP` = '%s', `Score` = '%d'", GetName(playerid), PlayerInfo[playerid][Password], GetIp(playerid), PlayerInfo[playerid][Score]);
    mysql_query(Query);
    print(Query);
}
Untested as I don't have windows installed to compile it.
Reply
#9

Edit: Dont matter.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)