sscanf with MYSQL
#1

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!
Reply
#2

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)