Password resets to "NoPassword" in MySQL
#1

Hello, Today I have made my GM script to set an update when the player disconnect the server.
but when you disconnect to the server password resets to " ".

Here is the code:

PHP код:
format(string,sizeof,(string),"UPDATE users SET Name = '%s' , Password = '%s'",Name,PlayerInfo[playerid][password]); 
I think that when I login it doesn't save my password to the one that I used in enum.
please help me fix this.
Reply
#2

That one line won't help us, show us the whole code of this part
Reply
#3

There is absolutely no reason to update the password when a player disconnects. Only if they get their password changed (by a command or other means).
Reply
#4

Okay just leave it. now I need this to be fixed.

PHP код:
format(query,sizeof(query),"UPDATE users SET Name = '%s' ,Password = '%s', PozX = '%f' , PozY = '%f' , PozZ = '%f' WHERE Name = '%s'",pName,PlayerInfo[playerid][Password],PlayerInfo[playerid][Position][0],PlayerInfo[playerid][Position][1],PlayerInfo[playerid][Position][2],pName); 
Код HTML:
CMySQLHandler::Query(UPDATE users SET Name = 'KizZweLL3' ,Password = 'save3', PozX = '1716.721069' , PozY = '-2242.138916' , PozZ = '-2.701581' WH) - An error has occured. (Error ID: 1064, You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WH' at line 1)
Reply
#5

Код:
format(query,sizeof(query),"UPDATE `users` SET `Name` = '%s' ,`Password` = '%s', `PozX` = '%f' , `PozY` = '%f' , `PozZ` = '%f' WHERE `Name` = '%s'",pName,PlayerInfo[playerid][Password],PlayerInfo[playerid][Position][0],PlayerInfo[playerid][Position][1],PlayerInfo[playerid][Position][2],pName);
Use this line instead of urs..
Reply
#6

Why are you update their name?
Reply
#7

Quote:
Originally Posted by Eoussama
Посмотреть сообщение
Why are you update their name?
My thoughts exactly.

KizZweLL, you should understand the concept of SQL. You update only those values that change.

The reason why it failed is probably not enough string size to hold the entire query.

Also using the player's name in WHERE clause in every query is slower (excluding the first query to determinate if account exists). Each player must have a unique ID (auto increment) and you identify the player by that value. Integer comparison is always faster than string comparison.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)