Get value from MySQL 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: Get value from MySQL Database (
/showthread.php?tid=624153)
Get value from MySQL Database -
NeroX98 - 11.12.2016
Hi
I have troubles with the new MySQL version.
I can't get string value:
Here is the query:
Код:
mysql_format(ServerDB, query, sizeof(query), "SELECT `Lozinka` FROM `igraci` WHERE `KorisnickoIme` = '%e'", ime[playerid]);
mysql_tquery(ServerDB, query, "ProveriAkaunt", "i", playerid);
Here is the callback:
Код:
public ProveriAkaunt(playerid) {
cache_get_value_name(0, iData[playerid][Lozinka], "Lozinka", 30);
printf("LOZ: %s", iData[playerid][Lozinka]);
return 1;
}
It prints just
LOZ: which means the variable is null.
Re: Get value from MySQL Database -
Sanady - 11.12.2016
Ok so, you have problem with query and public too, so first when you are getting name from database it should be %s (String) not %e. That what I notice so far.
Re: Get value from MySQL Database -
NeroX98 - 11.12.2016
Quote:
%e specifier escapes a string so we can avoid sql injection which means we don't have to use mysql_real_escape_string
|
BTW i get this error
Код:
[21:10:25] [ERROR] cache_get_value_name: empty field name
Re: Get value from MySQL Database -
Vince - 11.12.2016
Код:
Parameters:
(row_idx, const column_name[], destination[], max_len = sizeof(destination))
Means you have column name and destination switched. Takes a genius to figure that out.
Re: Get value from MySQL Database -
NeroX98 - 11.12.2016
Quote:
Originally Posted by Vince
Код:
Parameters:
(row_idx, const column_name[], destination[], max_len = sizeof(destination))
Means you have column name and destination switched. Takes a genius to figure that out.
|
Oh my god, THANKS!
There's no error but i still can't get the value. iData[playerid][Lozinka] is still null.