Retreiving data from my database?
#1

Hello,

This is my code:

Код:
    //-----Put data from table into PlayerStats variable-----
   	format(query, sizeof(query), "SELECT * FROM accounts WHERE username='%s'", playername);
	mysql_query(query);
	mysql_store_result();
	while(mysql_retrieve_row()){ //***************************************FINISH THIS .... look for a MYSQL RP script on forums!***********8
		new data[256];
		
		mysql_fetch_field_row(data, "username");
		playerStats[playerid][pUsername] = strval(data);
		printf("username: %s", data);
		
		mysql_fetch_field_row(data, "admin");
		playerStats[playerid][pAdmin] = strval(data);
		printf("admin: %d", data);
		
	}
	mysql_free_result();
The username field is working perfectly, but the admin field (int) is not working, it is storing "48" into the playerStats[playerid][pAdmin] section.....

Thanks if anyone can help...

this is the wiki for my mysql plugin im using:

https://sampwiki.blast.hk/wiki/MySQL
Reply
#2

Sure you haven't got it the wrong way around? Because strval evaluates a string and parses it as an integer, and I'd assume that a username would be a string.

pawn Код:
mysql_fetch_field_row(playerStats[playerid][pUsername], "username");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)