[MySQL] "cache_get_field_content_int" no active cache
#1

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.
Reply
#2

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?
Reply
#3

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;
}
Reply
#4

Quote:
Originally Posted by d3ll
View Post
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
View Post
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);
Reply
#5

Try this for iZn's method:

pawn Code:
cache_get_field_content(0, "IP", PlayerInfo[playerid][IP]);
Reply
#6

Quote:
Originally Posted by Faisal_khan
View Post
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.
Reply
#7

Quote:
Originally Posted by Faisal_khan
View Post
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);
Reply
#8

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));
Reply
#9

Quote:
Originally Posted by DobbysGamertag
View Post
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
Reply
#10

Quote:
Originally Posted by Kar
View Post
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
View Post
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
View Post
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)