SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 30/04/2011, 08:55 PM   #1
Georgelopez1
Huge Clucker
 
Georgelopez1's Avatar
 
Join Date: Sep 2010
Posts: 211
Reputation: 0
Default Mysql SavePlayer(playerid) error!

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

Heres the enum:

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

new PlayerInfo[MAX_PLAYERS][pInfo];

Now here's the Stock:

pawn Code:
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.
__________________
Hi, I'm George.
Georgelopez1 is offline  
Old 30/04/2011, 09:38 PM   #2
[L3th4l]
Guest
 
Posts: n/a
Default Re: Mysql SavePlayer(playerid) error!

Your syntax is wrong. http://www.w3schools.com/php/php_mysql_update.asp
 
Old 30/04/2011, 09:59 PM   #3
Georgelopez1
Huge Clucker
 
Georgelopez1's Avatar
 
Join Date: Sep 2010
Posts: 211
Reputation: 0
Default Re: Mysql SavePlayer(playerid) error!

Could you tell me what is wrong? I have seen 3 different ways to do this, and each time I try its wrong.
__________________
Hi, I'm George.
Georgelopez1 is offline  
Old 30/04/2011, 10:06 PM   #4
Retardedwolf
High-roller
 
Retardedwolf's Avatar
 
Join Date: Jun 2009
Posts: 1,466
Reputation: 60
Default Re: Mysql SavePlayer(playerid) error!

Code:
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.
Retardedwolf is offline  
Old 30/04/2011, 10:11 PM   #5
Zh3r0
High-roller
 
Join Date: Mar 2008
Posts: 4,512
Reputation: 398
Default Re: Mysql SavePlayer(playerid) error!

Since when score is a string? It's always numeric! Change it and set inside just %d at the Score column.
__________________
Zh3r0 is offline  
Old 30/04/2011, 11:55 PM   #6
Georgelopez1
Huge Clucker
 
Georgelopez1's Avatar
 
Join Date: Sep 2010
Posts: 211
Reputation: 0
Default Re: Mysql SavePlayer(playerid) error!

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')
__________________
Hi, I'm George.
Georgelopez1 is offline  
Old 01/05/2011, 05:01 PM   #7
Georgelopez1
Huge Clucker
 
Georgelopez1's Avatar
 
Join Date: Sep 2010
Posts: 211
Reputation: 0
Default Re: Mysql SavePlayer(playerid) error!

Ok so heres my stock now:


pawn Code:
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)
__________________
Hi, I'm George.
Georgelopez1 is offline  
Old 01/05/2011, 05:25 PM   #8
Calgon
Banned
 
Join Date: Jan 2009
Posts: 6,134
Reputation: 1127
Default Re: Mysql SavePlayer(playerid) error!

pawn Code:
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.
Calgon is offline  
Old 01/05/2011, 05:27 PM   #9
Kyle
High-roller
 
Kyle's Avatar
 
Join Date: Mar 2009
Location: United Kingdom
Posts: 2,260
Reputation: 330
Default Re: Mysql SavePlayer(playerid) error!

Edit: Dont matter.
Kyle is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Playerid Error Anthonyx3' Help Archive 3 09/01/2011 04:49 AM
RepairVehicle(GetPlayerVehicleID(playerid)); ERROR I need Help Abdulla_Alnuaimi Help Archive 2 26/05/2010 09:24 AM
error with playerid cssbart Help Archive 3 19/02/2010 07:07 AM
playerid error RenisiL Help Archive 3 14/08/2009 01:57 PM


All times are GMT. The time now is 07:09 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.