PDA

View Full Version : Won't load MySQL Data, Could someone explain why?


Dokins
02/04/2014, 10:16 PM
LoadAccount(playerid)
{
new QueryString[128];
mysql_query( "SELECT * FROM accounts WHERE `id` = %d", PlayerSQLID[playerid]);
mysql_store_result();
while(mysql_retrieve_row())
{
mysql_get_field( "Armour", QueryString);
PlayerArmour[playerid] = floatstr( QueryString);
SetPlayerArmour(playerid, PlayerArmour[playerid]);

mysql_get_field( "Level", QueryString);
PlayerLevel[playerid] = strval(QueryString);
SetPlayerScore(playerid, PlayerLevel[playerid]);

mysql_get_field( "Money", QueryString);
PlayerMoney[playerid] = strval(QueryString);
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, PlayerMoney[playerid]);

Report[playerid] = 0;
AdminDuty[playerid] = 0;

new ip[16];

GetPlayerIp(playerid, ip, sizeof(ip));
MySQL_SetString(PlayerSQLID[playerid], "PlayerIP",ip, "accounts");


mysql_get_field( "AdminLevel", QueryString);
AdminLevel[playerid] = strval(QueryString);

mysql_get_field( "UsingAccent", QueryString);
UsingAccent[playerid] = strval(QueryString);

if(UsingAccent[playerid] == 1)
{
LoadPlayerAccent(playerid);
}

mysql_get_field( "Faction", QueryString);
Faction[playerid] = strval(QueryString);

mysql_get_field( "FRank", QueryString);
FRank[playerid] = strval(QueryString);

mysql_get_field( "WepTime", QueryString);
WepTime[playerid] = strval(QueryString);

mysql_get_field( "WepID", QueryString);
WepID[playerid] = strval(QueryString);

mysql_get_field( "Skin", QueryString);
PlayerSkin[playerid] = strval(QueryString);

mysql_get_field( "HouseOwned", QueryString);
HouseOwned[playerid] = strval(QueryString);

mysql_get_field( "TotalTime", QueryString);
TotalTime[playerid] = strval(QueryString);

mysql_get_field( "Radio", QueryString);
Radio[playerid] = strval(QueryString);

mysql_get_field( "RadioFreq", QueryString);
RadioFreq[playerid] = strval(QueryString);

mysql_get_field( "Cellphone", QueryString);
Cellphone[playerid] = strval(QueryString);

mysql_get_field( "Phonebook", QueryString);
Phonebook[playerid] = strval(QueryString);

mysql_get_field( "Rope", QueryString);
Rope[playerid] = strval(QueryString);

mysql_get_field( "Cocaine", QueryString);
Cocaine[playerid] = strval(QueryString);

mysql_get_field( "Weed", QueryString);
Weed[playerid] = strval(QueryString);

mysql_get_field( "Jail", QueryString);
Jail[playerid] = strval(QueryString);

mysql_get_field( "BizOwned", QueryString);
BizOwned[playerid] = strval(QueryString);

mysql_get_field( "VMarker", QueryString);
VMarker[playerid] = strval(QueryString);

mysql_get_field( "FMarker", QueryString);
FMarker[playerid] = strval(QueryString);

mysql_get_field( "NMarker", QueryString);
NMarker[playerid] = strval(QueryString);

mysql_get_field( "SGrip", QueryString);
SGrip[playerid] = strval(QueryString);

mysql_get_field( "MGrip", QueryString);
MGrip[playerid] = strval(QueryString);

mysql_get_field( "LGrip", QueryString);
LGrip[playerid] = strval(QueryString);

mysql_get_field( "SFrame", QueryString);
SFrame[playerid] = strval(QueryString);

mysql_get_field( "MFrame", QueryString);
MFrame[playerid] = strval(QueryString);

mysql_get_field( "LFrame", QueryString);
LFrame[playerid] = strval(QueryString);

mysql_get_field( "SBarrel", QueryString);
SBarrel[playerid] = strval(QueryString);

mysql_get_field( "MBarrel", QueryString);
MBarrel[playerid] = strval(QueryString);

mysql_get_field( "LBarrel", QueryString);
LBarrel[playerid] = strval(QueryString);

mysql_get_field( "AdminJail", QueryString);
AdminJail[playerid] = strval(QueryString);
}
mysql_free_result();
return 1;
}

Jefff
02/04/2014, 10:28 PM
If you have problems with mysql please write which plugin version

use format for selects and limit 1
use mysql_fetch_row and sscanf for split string
use mysql debug mode for looking whats wrong

Dokins
02/04/2014, 10:33 PM
I'm not exactly an expert on MySQL. It's BlueG's R6. http://forum.sa-mp.com/showthread.php?t=56564

iZN
02/04/2014, 10:36 PM
What are the logs? MySQL logs.

Jefff
02/04/2014, 10:42 PM
format(QueryString,sizeof(QueryString),"SELECT * FROM accounts WHERE `id` = %d LIMIT 1",PlayerSQLID[playerid]);
mysql_query( QueryString );

Dokins
02/04/2014, 10:47 PM
I'll try that.

EDIT: Fixed.