MYSQL - weird bug
Hi, since i use MySql i have a bug on every plugin i use with MySql, i never found the problem.. till now!
The more players are on the server, the more often it happens. Currently there are 18/18 players on the server from ~12am till 1am and it happens like 2-3 times every day, so it's not much, but still annoying. I store the money in the database and give it to them when they rejoin the server. The database-structure looks like: steamid - name - money - more but not important But sometimes it happens that there are more entries for the same steamid and the money for the steamid is 0 or just the half. Example correct: STEAM_1:123 - Schwabba - 1000000 Examples wrong: STEAM_1:123 - Schwabba - 500000 STEAM_1:123 - Schwabba - -500000 or: STEAM_1:123 - Schwabba - 500000 STEAM_1:123 - Schwabba - 500000 or: STEAM_1:123 - Schwabba - 500000 STEAM_1:123 - Schwabba - 0 or: STEAM_1:123 - Schwabba - 0 STEAM_1:123 - Schwabba - 0 Sometimes there are 10 entries for the same player. PHP Code:
Someone know how that happens? |
Re: MYSQL - weird bug
Because you are selecting everything from that table and not those specific vars, the match isn't done so
PHP Code:
|
Re: MYSQL - weird bug
I got that from this tutorial: http://forums.alliedmods.net/showthr...&highlight=sql
But i dont have to use x = '%s' AND y = '%s' because i only wanna search the steamid. And you mean it's better to use PHP Code:
PHP Code:
|
Re: MYSQL - weird bug
No, i was said that your if condition will return true everytime and that's why you have duplicate entries.
PHP Code:
Code:
SELECT money FROM furienmoney WHERE steamid = '%s'And this it must to be executed in a proper function with the correct steamid to work. |
Re: MYSQL - weird bug
But then i can only get the money, not the other things in the database. It saves the money, played time, achievements etc. There are 83 fields in this database.
|
Re: MYSQL - weird bug
Don't listen to Clauu. His claims are wrong.
Your code doesn't look good. There is no need to insert data if noone was found while loading. You could just use "replace into ..." in Save_MySQL. Where do you execute Load_MySQL? |
Re: MYSQL - weird bug
Why i'm wrong?
PHP Code:
|
Re: MYSQL - weird bug
I suspect that the problem is caused by invalid steamid sent in the SELECT query (there is some checking in register_client to see if the steamid is correct, but there is none in Load_MySQL).
1. SQL_NumResults returns number of rows retrieved from database. If you execute SELECT ... WHERE steamid = '%s'; it will be greater than 0 for all steamids that are present in database so "if" condition will be false. 2. There is nothing wrong with SELECT * FROM ... 3. Using SQL_ReadResult to check if there were any rows retrieved from database is incorrect. |
Re: MYSQL - weird bug
Quote:
Quote:
Quote:
|
Re: MYSQL - weird bug
1 - in his code that if statement will be true everytime.
2 - it isn't but is much better to select only what you need. 3 - where in this topic did you see the use/encouragement of that? |
| All times are GMT -4. The time now is 23:30. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.