MySQL issues - 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: MySQL issues (
/showthread.php?tid=656497)
MySQL issues -
IdonTmiss - 17.07.2018
Well when I use this function to show a dialog and then see if the code is right i get the next error
pawn Код:
FUNCTION: OnAccCodesLoad(playerid)
{
cache_get_value_int(0, code", PlayerInfo[playerid][pCode]);
SPD(playerid, D_CHECK, DIALOG_STYLE_INPUT, "Name?", "{FFFFFF}Text", "Yeah", "Aha");
return true;
}
//and this is how i use it in that dialog
new string[130];
mysql_format(SQL, string, sizeof(string), "SELECT `code` FROM `users` WHERE `name`='%e' LIMIT 1", playerid);
mysql_tquery(SQL, string, "OnAccCodesLoad", "i", playerid);
Re: MySQL issues -
denNorske - 17.07.2018
What is the next error? Please let us know more.
Besides, what mysql version are you running?
Re: MySQL issues -
IdonTmiss - 17.07.2018
Quote:
Originally Posted by denNorske
What is the next error? Please let us know more.
Besides, what mysql version are you running?
|
Oh.. stupid me I forgot, and the plugin I'm using is: "R41-4"
PHP код:
[ERROR] cache_get_value_name_int: invalid row index '0' (number of rows: '0')
Re: MySQL issues -
Calisthenics - 17.07.2018
Check if there are rows first.
Re: MySQL issues -
Ivan_Ino - 17.07.2018
try from
Код:
cache_get_value_int(0, code", PlayerInfo[playerid][pCode]);
to
Код:
cache_get_value_int(0, "code", PlayerInfo[playerid][pCode]);
Re: MySQL issues -
IdonTmiss - 17.07.2018
Quote:
Originally Posted by Ivan_Ino
try from
Код:
cache_get_value_int(0, code", PlayerInfo[playerid][pCode]);
to
Код:
cache_get_value_int(0, "code", PlayerInfo[playerid][pCode]);
|
Nah still the same
Quote:
Originally Posted by Calisthenics
Check if there are rows first.
|
gonna try that
Re: MySQL issues -
Ivan_Ino - 17.07.2018
Add
Код:
printf("%d", mysql_num_rows());
on the line before
Код:
cache_get_value_int(0, "code", PlayerInfo[playerid][pCode]);
and check response looks like you're getting nothing back from a database
Re: MySQL issues -
Florin48 - 17.07.2018
PHP код:
new nume[25];
GetPlayerName(playerid,nume,sizeof(nume));
mysql_format(SQL, string, sizeof(string), "SELECT `code` FROM `users` WHERE `name`='%e' LIMIT 1", nume);
mysql_tquery(SQL, string, "OnAccCodesLoad", "i", playerid);
try now
Re: MySQL issues -
Ivan_Ino - 17.07.2018
Oh, of course, I see what an issue is, you are doing query wrong!
Код:
mysql_format(SQL, string, sizeof(string), "SELECT `code` FROM `users` WHERE `name`='%e' LIMIT 1", playerid);
Here you trying to fetch code based on user's name, but you're sending player's id instead of player's name
That is why you getting nothing back from db
Re: MySQL issues -
IdonTmiss - 17.07.2018
Quote:
Originally Posted by Ivan_Ino
Add
Код:
printf("%d", mysql_num_rows());
on the line before
Код:
cache_get_value_int(0, "code", PlayerInfo[playerid][pCode]);
and check response looks like you're getting nothing back from a database
|
Looks like that I added "cache_get_row_count" and !rows ofc it returns nothing...