19.06.2014, 14:47
Hello, I am having trouble retrieving data from my MySQL database and was wondering if you guys could help. I am receiving no errors or warnings.
This is the code to start the function:
'cache_get_field_content' does not contain any of the data from any of the tables on the database from username, amount or the id. Does anyone know how I can fix this?
Thanks in advance!
This is the code to start the function:
pawn Код:
CMD:darkmoonme(playerid,params[])
{
new query[80];
new sendername[200];
GetPlayerName(playerid, sendername, sizeof(sendername));
//format(Query,sizeof(Query),"SELECT * FROM postback WHERE username = '%s'", sendername);
//mysql_tquery(dbHandle, Query, "SendPostback", "");
format(query, sizeof(query), "SELECT * FROM `postback` WHERE username = 'Lewis_Ryan'");
mysql_function_query(handle, query, false, "SendPostback", "i",playerid);
return 1;
}
pawn Код:
forward SendPostback(playerid);
public SendPostback(playerid)
{
new standardstring[500];
cache_get_data(rows, fields, handle);
if(rows != 0)
{
new amount[200], amountval, playername[200], mysqlid,query[200], tmp[200];
cache_get_field_content(0, "username", tmp), format(playername, 128, tmp);
cache_get_field_content(0, "amount", amount); amountval = strval(amount);
cache_get_field_content(0, "id", tmp); mysqlid = strval(tmp);
format(standardstring, sizeof(standardstring), "{00FFFF}[Announcements]{FFFF00} (Postback Donations) Thank you, %s, for purchasing %d VIP Points and helping to support the server!",playername, amountval);
SendClientMessageToAll(-1, standardstring);
format(query, sizeof(query), "DELETE FROM `postback` WHERE id = '%d'", mysqlid);
mysql_tquery(handle, query, "", "");
}
else
{
SendClientMessageToAll(-1, "MYSQL QUERY, NOT FOUND IN DATABASE");
}
}