[DEBUG] mysql_format - connection: 1, len: 60, format: "SELECT `Username` from `players` WHERE `IP` = '%s'" [DEBUG] mysql_tquery - connection: 1, query: "SELECT `Username` from `players` WHERE `IP` = ' '", callback: "CheckAka", format: "i" [DEBUG] CMySQLQuery::Execute[CheckAka] - starting query execution [DEBUG] CMySQLQuery::Execute[CheckAka] - query was successfully executed within 1.230 milliseconds [DEBUG] CMySQLResult::CMySQLResult() - constructor called [DEBUG] Calling callback "CheckAka".. [DEBUG] cache_get_data - connection: 1 [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
CMD:aka(playerid, params[])
{
new query[60],pIP[16];
mysql_format(mysql, query, sizeof(query),"SELECT `Username` from `players` WHERE `IP` = '%s'", GetPlayerIp(playerid,pIP,sizeof(pIP)));
mysql_tquery(mysql, query, "CheckAka", "i", playerid);
return 1;
}
function CheckAka(playerid)
{
new rows, fields;
cache_get_data(rows, fields, mysql);
if(rows)
{
cache_get_field_content(rows, "Username", Name[playerid]);
SendFM(playerid, -1, "AKA: %s",Name[playerid]);
}
return 1;
}
CMD:aka(playerid, params[])
{
new query[60],pIP[16];
GetPlayerIp(playerid,pIP,sizeof(pIP));
mysql_format(mysql, query, sizeof(query),"SELECT `Username` from `players` WHERE `IP` = '%s'", pIP );
mysql_tquery(mysql, query, "CheckAka", "i", playerid);
return 1;
}
Basically GetPlayerIp returns 1 on success and 0 on failure.So what you doing is wrong logically.
You can do it like this way. PHP код:
|
[17:40:29] [DEBUG] mysql_format - connection: 1, len: 60, format: "SELECT `Username` from `players` WHERE `IP` = '%s'"
[17:40:29] [DEBUG] mysql_tquery - connection: 1, query: "SELECT `Username` from `players` WHERE `IP` = ''", callback: "CheckAka", format: "i"
[17:40:29] [DEBUG] CMySQLQuery::Execute[CheckAka] - starting query execution
[17:40:29] [DEBUG] CMySQLQuery::Execute[CheckAka] - query was successfully executed within 0.784 milliseconds
[17:40:30] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[17:40:30] [DEBUG] Calling callback "CheckAka"..
[17:40:30] [DEBUG] cache_get_data - connection: 1
[17:40:30] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
CMD:aka(playerid, params[])
{
new query[60],pIP[16];
GetPlayerIp(playerid,pIP,sizeof(pIP));
mysql_format(mysql, query, sizeof(query),"SELECT `Username` from `players` WHERE `IP` = '%s'", pIP);
mysql_tquery(mysql, query, "CheckAka", "i", playerid);
return 1;
}
function CheckAka(playerid)
{
new rows, fields;
cache_get_data(rows, fields, mysql);
if(rows)
{
cache_get_field_content(rows, "Username", Name[playerid]);
SendFM(playerid, -1, "AKA: %s",Name[playerid]);
}
return 1;
}
CMD:aka(playerid, params[])
{
new query[60],pIP[16];
GetPlayerIp(playerid,pIP,sizeof(pIP));
printf("ip is %s",pIP);
mysql_format(mysql, query, sizeof(query),"SELECT `Username` from `players` WHERE `IP` = '%s'", pIP);
mysql_tquery(mysql, query, "CheckAka", "i", playerid);
return 1;
}
function CheckAka(playerid)
{
new rows, fields;
cache_get_data(rows, fields, mysql);
if(rows)
{
cache_get_field_content(rows, "Username", Name[playerid]);
SendFM(playerid, -1, "AKA: %s",Name[playerid]);
}
return 1;
}
If you copy the query to notepad and fill in the full length of an IP address, your query is too short:
SELECT `Username` from `players` WHERE `IP` = '123.123.123.123' This query counts 63 characters and you also need a null char to end the string, so your query needs to be at least 64 chars long, 60 is too short. |
function CheckAka(playerid)
{
new rows, fields;
cache_get_data(rows, fields, mysql);
if(rows)
{
cache_get_field_content(0, "Username", Name[playerid]);
SendFM(playerid, -1, "AKA: %s",Name[playerid]);
}
return 1;
}
Updated query size.
How it will print each name that is under the same IP? It prints only the first it finds. For example i have at ID 1 MrJohnnz and at ID 2 Username [GT]Ryder with the same ip but it shows me only the first one . PHP код:
|