mysql problem - 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 problem (
/showthread.php?tid=317430)
[solved]mysql problem -
s0cket - 11.02.2012
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:
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.
Re: mysql problem -
Tanush123 - 11.02.2012
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?
Re: mysql problem -
[LoF]Zak - 11.02.2012
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?
Re: mysql problem -
s0cket - 11.02.2012
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!
Re: mysql problem -
[LoF]Zak - 11.02.2012
Heh. I tend to do silly mistakes like these myself actually :P. Glad you fixed it though