mysql problem
#1

I really can't figure out what's wrong with this code, I've done a similar script before and it worked fine.

gangid[playerid] is this global variable array:
pawn Код:
new gangid[MAX_PLAYERS];
and username variable is this:
pawn Код:
new username[MAX_PLAYER_NAME];
GetPlayerName(playerid, username, sizeof(username));
pawn Код:
new checkgangQuery[250];
format (checkgangQuery, sizeof(checkgangQuery), "SELECT `gangid` FROM `users` WHERE `username` = '%s'", username);
mysql_query(checkgangQuery);
mysql_store_result();
gangid[playerid] = mysql_fetch_int();
mysql_free_result();
new debugstring[50];
format(debugstring, sizeof(debugstring), "%s", gangid[playerid]);
SendClientMessage(playerid, 0xFFFFFFAA, debugstring);
when I run this code debug string comes empty, or with text if I add it and an empty space in place of the gangid[playerid] variable.
This is the output I get if I run a similar sql query in phpmyadmin:


I also tried replacing gangid array with a single variable and a different array, result was the same.
Reply
#2

this code
pawn Код:
new checkgangQuery[250];
format (checkgangQuery, sizeof(checkgangQuery), "SELECT `gangid` FROM `users` WHERE `username` = '%s'", username);
mysql_query(checkgangQuery);
mysql_store_result();
gangid[playerid] = mysql_fetch_int();
mysql_free_result();
new debugstring[50];
format(debugstring, sizeof(debugstring), "%s", gangid[playerid]);
SendClientMessage(playerid, 0xFFFFFFAA, debugstring);
is when somebody logs in right?
Reply
#3

pawn Код:
format(debugstring, sizeof(debugstring), "%s", gangid[playerid]);
to:

pawn Код:
format(debugstring, sizeof(debugstring), "%d", gangid[playerid]);
?? gangid[playerid] is a int not a string right?
Reply
#4

Quote:
Originally Posted by [LoF]Zak
Посмотреть сообщение
playerid] is a int not a string right?
It was, can't believe I misused it like that . Thank you for your help!
Reply
#5

Heh. I tend to do silly mistakes like these myself actually :P. Glad you fixed it though
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)