SA-MP Forums Archive
[MySQL] Repeating - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [MySQL] Repeating (/showthread.php?tid=160145)



[MySQL] Repeating - ScottCFR - 15.07.2010

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.




Re: [MySQL] Repeating - [HiC]TheKiller - 15.07.2010

Show your registering system.


Re: [MySQL] Repeating - ScottCFR - 15.07.2010

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.



Re: [MySQL] Repeating - [HiC]TheKiller - 15.07.2010

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


Re: [MySQL] Repeating - oliverrud - 15.07.2010

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


Re: [MySQL] Repeating - ScottCFR - 15.07.2010

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


Re: [MySQL] Repeating - [HiC]TheKiller - 15.07.2010

The part in the register system where it uses insert.


Re: [MySQL] Repeating - ScottCFR - 15.07.2010

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


Re: [MySQL] Repeating - [HiC]TheKiller - 15.07.2010

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.


Re: [MySQL] Repeating - WackoX - 16.07.2010

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.