SQL Insert and Update Player Info
1 Attachment(s)
Player info is registering MYSQL to update, but does not update. Can you help me?
(ip, name, authid, hp, alive or dead Code:
new Handle:Query = SQL_PrepareQuery(SqlConnection, "INSERT INTO `playerlogger` (`ip`, `name`, `authid`, `hp`, `df_canli`) VALUES ('%s','%s','%s','%i','%i') ON DUPLICATE KEY UPDATE `ip`=VALUES(`ip`), `name`=VALUES(`name`), `authid`=VALUES(`authid`), `hp`=VALUES(`hp`), `df_canli`=VALUES(`df_canli`);", szIP, szName, szAuthid, iL_HP, df_canli); |
Re: SQL Insert and Update Player Info
Do debugging and see where your code fails.
|
Re: SQL Insert and Update Player Info
This query is totally wrong. Why you supposed to updated inserted record?
|
Re: SQL Insert and Update Player Info
Can you do the right thing?
Because players want to reflect the view. You can look here as an example https://www.csduragi.com/monitor/cs8.csduragi.net |
Re: SQL Insert and Update Player Info
Use replace instead .
|
Re: SQL Insert and Update Player Info
Quote:
can you give me information about how to use it? |
Re: SQL Insert and Update Player Info
You need to include a primary key in the statement otherwise it will work the same as insert. If any fields in the record have a value then you must include them in the statement, even if they are not being changed, otherwise they will be set to null. In the below example my primary key in the table is ID, set to auto-increment to make inserting new records easy.
Suppose I have the below record: ID = 223 SteamID = STEAM_0:1:12345 PlayerName= bugsy PlayTime= 555 I can then do the below to update PlayTime to 123. Fields SteamID & PlayerName will remain unchanged since I am including the existing values in the statement. Code:
REPLACE INTO tblPlayerData (ID, SteamID, PlayerName, PlayTime) VALUES (223,'STEAM_0:0:12345','bugsy',123); Assume these fields exist in a row: ID = 223 SteamID = STEAM_0:1:12345 PlayerName= bugsy PlayTime= 555 XPPoints = 555 Code:
REPLACE INTO tblPlayerData (ID, SteamID, PlayerName, PlayTime, XPPoints) VALUES (223,'STEAM_0:0:12345','bugsy',123,555); When adding a new record, just exclude the ID field and it will add a new record, advancing ID to the next slot automatically. Code:
REPLACE INTO tblPlayerData (SteamID, PlayerName) VALUES ('STEAM_0:0:555','bugsy2'); |
Re: SQL Insert and Update Player Info
Quote:
thank you for the answer so can you ask me to do this sma coding I don't have many resources because I am Turkish so I will be forced I need help because it has a different structure than php |
Re: SQL Insert and Update Player Info
Code:
public RegisterUser(id){ |
All times are GMT -4. The time now is 07:52. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.