Retreiving data from my database? - 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: Retreiving data from my database? (
/showthread.php?tid=175071)
Retreiving data from my database? -
DarrenReeder - 08.09.2010
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
Re: Retreiving data from my database? -
Calgon - 08.09.2010
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");