SA-MP Forums Archive
Problem with obtaining information from my database - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem with obtaining information from my database (/showthread.php?tid=651813)



Problem with obtaining information from my database - Denying - 28.03.2018

Hello,

I'm using a MySQL plugin, R41-4 to be precise.

I make a tquery and within the callback I use "cache_get_value_name(0, "Password", pInfo[playerid][Password]);"

Now, I checked and the value returned is null. I have no value whatsoever there.
The logs say:

[17:36:14] [DEBUG] cache_get_value_name(0, "Password", 0x04CA62DC, 1)
[17:36:14] [DEBUG] cache_get_value_name: assigned value: 'censored'
[17:36:14] [DEBUG] cache_get_value_name: return value: '1'

and replace censored with my actual password.

It seems to get the value properly, just not insert it into my string. Any thoughts on what I might be doing wrong?

Thank you in advance,
Denying


Re: Problem with obtaining information from my database - jasperschellekens - 28.03.2018

What about showing code?


Re: Problem with obtaining information from my database - kovac - 28.03.2018

0x04CA62DC, you should replace that color with your variable lol


Re: Problem with obtaining information from my database - Denying - 28.03.2018

Here's the code in question:

OnPlayerConnect:

Код:
mysql_format(mysql, query, sizeof(query), "SELECT `Password`, `ID` FROM `Users` WHERE `Username` = '%e' LIMIT 1", playerName);
mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);
OnAccountCheck:

Код:
new rows;
	
cache_get_row_count(rows);
	
if(rows)
{
    cache_get_value_name(0, "Password", pInfo[playerid][Password]);
    cache_get_value_name_int(0, "ID", pInfo[playerid][ID])
}
As you can see, I did not type a number (or address), rather, I typed a string.


Re: Problem with obtaining information from my database - X337 - 28.03.2018

wiki: "Important Note: You have to provide the size (max_len) by yourself if you use an enum-array as destination."

https://sampwiki.blast.hk/wiki/MySQL/R40...get_value_name


Re: Problem with obtaining information from my database - Denying - 28.03.2018

*facepalm*

I've been through the wiki over and over again trying to see what I am missing...

Anyway, thank you very much. +rep


Re: Problem with obtaining information from my database - kovac - 28.03.2018

Try this and don't forget to change the length to match your needs.

cache_get_value_name(0, "Password", pInfo[playerid][Password], 130);

By the way, stealing passwords is disgusting.


Re: Problem with obtaining information from my database - ForCop - 28.03.2018

Quote:
Originally Posted by Denying
Посмотреть сообщение
Here's the code in question:

OnPlayerConnect:

Код:
mysql_format(mysql, query, sizeof(query), "SELECT `Password`, `ID` FROM `Users` WHERE `Username` = '%e' LIMIT 1", playerName);
mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);
OnAccountCheck:

Код:
new rows;
	
cache_get_row_count(rows);
	
if(rows)
{
    cache_get_value_name(0, "Password", pInfo[playerid][Password]);
    cache_get_value_name_int(0, "ID", pInfo[playerid][ID])
}
As you can see, I did not type a number (or address), rather, I typed a string.
do not need it OnAccountCheck
Код:
mysql_format(mysql, query, sizeof(query), "SELECT `Password`, `ID` FROM `Users` WHERE `Username` = '%e' LIMIT 1", playerName);
new Cache:result = mysql_query(mysql,query);
if(cache_num_rows() > 0) {
	cache_get_value_name(0, "Password", pInfo[playerid][Password]);
	cache_get_value_name_int(0, "ID", pInfo[playerid][ID])
}
cache_delete(result);