SA-MP Forums Archive
sscanf with MYSQL - 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: sscanf with MYSQL (/showthread.php?tid=157687)



sscanf with MYSQL - Kyleee - 07.07.2010

Hello guys, I have a problem when I try to load data from a mysql database.


Код:
//Part 1
		format(queryEX,512,"SELECT `Name`,`Money`,`Bank` FROM `players` WHERE `id`='%d'",PlayerInfo[playerid][pSQLID]);

		mysql_query(queryEX);
		mysql_store_result();
		mysql_fetch_row_format(resultEX,"|");
		mysql_free_result();
		sscanf(resultEX,"p|sdd",
		PlayerInfo[playerid][pName],
		PlayerInfo[playerid][pMoney],
		PlayerInfo[playerid][pBank]

//Part2

		format(queryEX,512,"SELECT `Sex`,`Origin` FROM `players` WHERE `id`='%d'",PlayerInfo[playerid][pSQLID]);

		mysql_query(queryEX);
		mysql_store_result();
		mysql_fetch_row_format(resultEX,"|");
		mysql_free_result();
		sscanf(resultEX,"p|dd",
		PlayerInfo[playerid][pSex],
		PlayerInfo[playerid][pOrigin]
The problem is when I load the Part 2 it puts in PlayerInfo[playerid][pSex] the `Name` from the Part1.
Is there a way to fix this? I don't want to load all the parameters in one string.

Thank you guys!


Re: sscanf with MYSQL - Kyleee - 07.07.2010

Can you please give me the link? I can't find it.
Thank you for your answer.

EDIT: I found the link and it works, thank you!

Another question, why do I need to add the p| ?
When I don't add p| to the sscanf it won't work.