[MySQL] Repeating
#1

I'm having trouble with my MySQL. Everytime someone registers. It copys their name over everyone elses. I can't find anything different in the logs.

Reply
#2

Show your registering system.
Reply
#3

I don't feel comfortable showing that publically. But I found an error in my logs:
Код:
MySQL Error (0): Could not execute 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 '' at line 1.
Reply
#4

I cant do much then, I have no idea what the mistake in your script is.
Reply
#5

If you wont show us your script then we can't do anything about it.
Reply
#6

Well, exactly what parts do you need? This never happened before so that's why it's confusing.
Reply
#7

The part in the register system where it uses insert.
Reply
#8

This is register:
Код:
format(query,sizeof(query),"INSERT INTO users (name, password) VALUES ('%s', '%s')",name,password);
This is update:
Код:
format(query,sizeof(query),"UPDATE users SET name='%s', password='%s', admin=%d, cash=%d, score=%d WHERE SQLid=%d",name,AccountInfo[playerid][Password],AccountInfo[playerid][AdminLevel],AccountInfo[playerid][Cash],AccountInfo[playerid][Score],AccountInfo[playerid][mglvl],AccountInfo[playerid][SQLid]);
This may be usefule GetPlayerSQLid:
Код:
format(query,sizeof(query),"SELECT SQLid FROM users WHERE name='%s'",name);
This is the SQL system I use:
https://sampforum.blast.hk/showthread.php?tid=122983
Reply
#9

Put this under the update string.

pawn Код:
printf("%d", AccountInfo[playerid][SQLid]);
Does it give the correct SQLID? It may be sending back null and that will overwrite all of them.
Reply
#10

Quote:
Originally Posted by ScottCFR
Посмотреть сообщение
This is update:
Код:
format(query,sizeof(query),"UPDATE users SET name='%s', password='%s', admin=%d, cash=%d, score=%d WHERE SQLid=%d",name,AccountInfo[playerid][Password],AccountInfo[playerid][AdminLevel],AccountInfo[playerid][Cash],AccountInfo[playerid][Score],AccountInfo[playerid][mglvl],AccountInfo[playerid][SQLid]);
You people are blind, i saw this in the first place:

Код:
format(query,sizeof(query),"UPDATE users SET name='%s', password='%s', admin='%d', cash='%d', score='%d' WHERE name='%s'",name,AccountInfo[playerid][Password],AccountInfo[playerid][AdminLevel],AccountInfo[playerid][Cash],AccountInfo[playerid][Score],AccountInfo[playerid][mglvl],name);
You forgot a lot of '.
Also you'll have to make SQLid an AUTO_INCREMENT.
Also, don't look for SQLid when you update a player, look for he's name.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)