[MySQL] "cache_get_field_content_int" no active cache -
Faisal_khan - 10.06.2014
Hi guys,
Well this is my code:
pawn Code:
SendClientMessage(playerid, COLOR_YELLOW, "You have succesfully logged in!");
IsLogged[playerid] = 1;
mysql_format(mysql, query, sizeof(query), "SELECT * FROM playerdata WHERE Name = '%e' LIMIT 1", PlayerInfo[playerid][name]);
mysql_tquery(mysql, query, "LoadAccount", "d", playerid);
LoadAccount:
pawn Code:
forward LoadAccount(playerid);
public LoadAccount(playerid)
{
new rows, fields;
cache_get_data(rows, fields);
PlayerInfo[playerid][IP] = cache_get_field_content_int(0, "IP");
}
I tried using mysql_function_query, still no luck.
Regards.
Re: [MySQL] "cache_get_field_content_int" no active cache -
d3ll - 10.06.2014
pawn Code:
forward LoadAccount(playerid);
pawn Code:
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `playerdata` WHERE `Name` = '%s' LIMIT 1", pname);
mysql_tquery(mysql, query, "LoadAccount", "i", playerid);
pawn Code:
public LoadAccount(playerid)
{
cache_get_field_content(0, "IP", PlayerInfo[playerid][IP]);
IsLogged[playerid] = 1;
return 1;
}
Try this, IP has to get loaded as a string no?
Re: [MySQL] "cache_get_field_content_int" no active cache -
iZN - 10.06.2014
pawn Code:
forward LoadAccount(playerid);
public LoadAccount(playerid)
{
if(!cache_get_row_count())
{
// No registration found - they need to be registered!
return true;
}
new szQuery[16];
// Now we will continue in order to complete our query
format(szQuery, sizeof(szQuery), "%s", PlayerInfo[playerid][IP]);
cache_get_field_content(0, "IP", szQuery);
return true;
}
Re: [MySQL] "cache_get_field_content_int" no active cache -
Faisal_khan - 10.06.2014
Quote:
Originally Posted by d3ll
pawn Code:
forward LoadAccount(playerid);
pawn Code:
new pname[MAX_PLAYER_NAME]; GetPlayerName(playerid, pname, sizeof(pname)); mysql_format(mysql, query, sizeof(query), "SELECT * FROM `playerdata` WHERE `Name` = '%s' LIMIT 1", pname); mysql_tquery(mysql, query, "LoadAccount", "i", playerid);
pawn Code:
public LoadAccount(playerid) { cache_get_field_content(0, "IP", PlayerInfo[playerid][IP]); IsLogged[playerid] = 1; return 1; }
Try this, IP has to get loaded as a string no?
|
Yeah. I tried that already same error.
Quote:
Originally Posted by iZN
pawn Code:
forward LoadAccount(playerid); public LoadAccount(playerid) { if(!cache_get_row_count()) { // No registration found - they need to be registered! return true; }
new szQuery[16];
// Now we will continue in order to complete our query PlayerInfo[playerid][IP] = cache_get_field_content(0, "IP", szQuery); return true; }
|
Gives an argument mismatch here:
pawn Code:
PlayerInfo[playerid][IP] = cache_get_field_content(0, "IP", szQuery);
Re: [MySQL] "cache_get_field_content_int" no active cache -
d3ll - 10.06.2014
Try this for iZn's method:
pawn Code:
cache_get_field_content(0, "IP", PlayerInfo[playerid][IP]);
Re: [MySQL] "cache_get_field_content_int" no active cache -
KtotheYle - 10.06.2014
Quote:
Originally Posted by Faisal_khan
Hi guys,
Well this is my code:
pawn Code:
SendClientMessage(playerid, COLOR_YELLOW, "You have succesfully logged in!"); IsLogged[playerid] = 1; mysql_format(mysql, query, sizeof(query), "SELECT * FROM playerdata WHERE Name = '%e' LIMIT 1", PlayerInfo[playerid][name]); mysql_tquery(mysql, query, "LoadAccount", "d", playerid);
LoadAccount:
pawn Code:
forward LoadAccount(playerid); public LoadAccount(playerid) { new rows, fields; cache_get_data(rows, fields); PlayerInfo[playerid][IP] = cache_get_field_content_int(0, "IP"); }
I tried using mysql_function_query, still no luck.
Regards.
|
pawn Code:
forward LoadAccount(playerid);
public LoadAccount(playerid)
{
new rows, fields;
cache_get_data(rows, fields);
if(rows)
{
//This runs if there is data in the DB
cache_get_field_content(0, "IP", PlayerInfo[playerid][IP], .max_len = 44);
}
else
{
//If nothing is there
}
}
You were trying to get IP as a int, which it is not because it has decimals, nor is it a float because there are multiple decimals, so your easiest way is to make it a string. You could also do this
GetPlayerIp(playerid, PlayerInfo[playerid][IP], 44);
Also make sure that the max length of your IP is the same as what is described as your maxlength.
Re: [MySQL] "cache_get_field_content_int" no active cache -
iZN - 10.06.2014
Quote:
Originally Posted by Faisal_khan
Yeah. I tried that already same error.
Gives an argument mismatch here:
pawn Code:
PlayerInfo[playerid][IP] = cache_get_field_content(0, "IP", szQuery);
|
Oh right I almost forgot!
pawn Code:
format(szQuery, sizeof(szQuery), "%s", PlayerInfo[playerid][IP]);
cache_get_field_content(0, "IP", szQuery);
Re: [MySQL] "cache_get_field_content_int" no active cache -
DobbysGamertag - 10.06.2014
Why not use:
pawn Code:
if(cache_num_rows())//exists
{
//code
}
Plus, to get a string, the syntax:
pawn Code:
cache_get_field_content(row, field_name[], destination[], connectionHandle = 1, max_len = sizeof(destination));
Re: [MySQL] "cache_get_field_content_int" no active cache -
KtotheYle - 10.06.2014
Quote:
Originally Posted by DobbysGamertag
Why not use:
pawn Code:
if(cache_num_rows())//exists { //code }
Plus, to get a string, the syntax:
pawn Code:
cache_get_field_content(row, field_name[], destination[], connectionHandle = 1, max_len = sizeof(destination));
|
If he already connected to the DB he doesn't want to have the connectionHandle = 1, for me in the past that has caused errors for MySQL.
And mine checking if it exist works the same as yours does, person preference :P
Re: [MySQL] "cache_get_field_content_int" no active cache -
Faisal_khan - 11.06.2014
Quote:
Originally Posted by Kar
That's not true.
And maybe the guy has multiple connections?
pawn Code:
SendClientMessage(playerid, COLOR_YELLOW, "You have succesfully logged in!"); IsLogged[playerid] = 1; mysql_format(mysql, query, sizeof(query), "SELECT * FROM `playerdata` WHERE `Name` = '%e' LIMIT 1", PlayerInfo[playerid][name]); mysql_tquery(mysql, query, "LoadAccount", "d", playerid);
forward LoadAccount(playerid); public LoadAccount(playerid) { new rows = cache_num_rows(); if(!rows) { printf("[DATABASE ERROR]: Account does not exist."); } else if(rows == 1) { PlayerInfo[playerid][IP] = cache_get_field_content(0, "IP", PlayerInfo[playerid][IP], mysql, 17); } else if(rows > 1) { printf("[DATABASE ERROR]: Multiple accounts matching player %d.", playerid); } }
|
No, only one connection. It is still giving me the "no active cache" warning. And no errors.
Quote:
Originally Posted by iZN
Oh right I almost forgot!
pawn Code:
format(szQuery, sizeof(szQuery), "%s", PlayerInfo[playerid][IP]); cache_get_field_content(0, "IP", szQuery);
|
Still same problem.
Quote:
Originally Posted by KtotheYle
pawn Code:
forward LoadAccount(playerid); public LoadAccount(playerid) { new rows, fields; cache_get_data(rows, fields); if(rows) { //This runs if there is data in the DB cache_get_field_content(0, "IP", PlayerInfo[playerid][IP], .max_len = 44); } else { //If nothing is there } }
You were trying to get IP as a int, which it is not because it has decimals, nor is it a float because there are multiple decimals, so your easiest way is to make it a string. You could also do this
GetPlayerIp(playerid, PlayerInfo[playerid][IP], 44);
Also make sure that the max length of your IP is the same as what is described as your maxlength.
|
Still same problem. Yeah I modified the code for the string.