Getting name from SQL, returns inputtext?! -
Dokins - 04.08.2015
pawn Код:
stock GetSQLName(playersqlid)
{
new szQuery[256];
format(szQuery, sizeof(szQuery), "SELECT `PlayerName` FROM `accounts` WHERE `id` = %d", playersqlid);
mysql_tquery(dbHandle, szQuery, "SQLName", "");
return 1;
}
forward SQLName();
public SQLName()
{
new result[64];
return cache_get_row(0, 0, result);
}
When I pickup a pickup it returns the command I typed or whatever?
Re: Getting name from SQL, returns inputtext?! -
Beckett - 04.08.2015
Can I see how the way you're using it?
That's way more than your needs though, up to you to reduce it.
Re: Getting name from SQL, returns inputtext?! -
Dokins - 04.08.2015
I know, I was testing it.
pawn Код:
OwnedString[x] = format(string, sizeof(string), "~g~Address:~w~ %s ~n~ ~g~Owner:~w~ %s", HouseName[x], GetSQLName(HouseOwner[x]));
Re: Getting name from SQL, returns inputtext?! -
Beckett - 04.08.2015
pawn Код:
forward SQLName();
public SQLName()
{
new result[64];
cache_get_row(0, 0, result);
print(result);
return result;
}
Try to use it in a command or where-ever. What does it print?
Re: Getting name from SQL, returns inputtext?! -
Dokins - 04.08.2015
It prints whatever I typed in chat.
Re: Getting name from SQL, returns inputtext?! -
Jefff - 04.08.2015
Use old mysql style xd
pawn Код:
stock GetSQLName(playersqlid)
{
new Cache:result, string[128];
format(string, sizeof(string), "SELECT `PlayerName` FROM `accounts` WHERE `id` = %d LIMIT 1", playersqlid);
result = mysql_query(dbHandle, string);
string = "N/A"; // if id doesnt exist
if(cache_num_rows())
cache_get_row(0, 0, string, dbHandle, MAX_PLAYER_NAME);
cache_delete(result);
return string;
}
Re: Getting name from SQL, returns inputtext?! -
Dokins - 04.08.2015
Facepalm. THANK YOU!
Re: Getting name from SQL, returns inputtext?! -
Beckett - 04.08.2015
I believe the whole idea of that stock is wrong. Since public functions can not return arrays, which you are doing in that case. Calling the stock, stock calling the public function which returns an array, which is impossible.
If you go ahead and try to compile these lines:
Код:
forward SQLName();
public SQLName()
{
new result[64];
return result;
}
Код:
error 090: public functions may not return arrays (symbol "SQLName")
But somehow that cache_get_row function is hiding the error.
Edit: Seems like you solved it, good luck.
Re: Getting name from SQL, returns inputtext?! -
Dokins - 04.08.2015
Thank you.