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=443162)
MYSQL problem -
Richie© - 10.06.2013
Im trying to get the last 10 logins to show up, 'Player Name' logged in 'date and time'.
It shows me 'Richie© logged in NULL'. Why?
Field 'PlayerName' is varchar 24, 'Time' is varchar 20 in the DB.
pawn Код:
IRCCMD:lastlogins(botid, channel[], user[], host[], params[])
{
if (IRC_IsOp(botid, channel, user))
{
mysql_function_query(gConnectionhandle, "SELECT DISTINCT `PlayerName` FROM `lol_Players` ORDER BY `Time` DESC LIMIT 10", true, "iLast10Logins", "s", channel);
}
return 1;
}
forward iLast10Logins(channel[]);
public iLast10Logins(channel[])
{
new rows, fields, time[20], user[24], string[60];
cache_get_data(rows, fields);
IRC_GroupSay(gGroupID, channel, "________ Last 10 Logins ________");
for(new i=0; i<rows; i++)
{
cache_get_field_content(i, "PlayerName", user);
cache_get_field_content(i, "Time", time);
format(string, sizeof(string), "%s logged in %s", user, time);
IRC_GroupSay(gGroupID, channel, string);
}
return 1;
}
Re: MYSQL problem -
SuperViper - 10.06.2013
You aren't selecting the time column in the query.
Re: MYSQL problem -
Richie© - 10.06.2013
Oh, so i have to;
pawn Код:
SELECT DISTINCT `PlayerName`, `Time` ...
Edit: Yes, i had to! Thanks SuperViper!

i thought it would return entire row, but i was wrong.
Re: MYSQL problem -
Richie© - 11.06.2013
SuperViper's solution did not work as i hoped for.
Select's 10 last players, excluding relogs. But shows Time as NULL.
pawn Код:
SELECT DISTINCT `PlayerName` FROM `lol_Players` ORDER BY `Time` DESC LIMIT 10
Shows Time correctly, but does not exclude 'relogs'.
pawn Код:
SELECT DISTINCT `PlayerName`, `Time` FROM `lol_Players` ORDER BY `Time` DESC LIMIT 10
pawn Код:
[22:26] <SA-TDM[1]> ________ Last 10 Logins ________
[22:26] <SA-TDM[0]> givi.koguashvili logged in 11/06/2013 8:35
[22:26] <SA-TDM[0]> Uros_Andjelkovic logged in 11/06/2013 8:29
[22:26] <SA-TDM[0]> mohamed logged in 11/06/2013 8:27
[22:26] <SA-TDM[0]> BOSS2013 logged in 11/06/2013 8:17
[22:26] <SA-TDM[1]> givi.koguashvili logged in 11/06/2013 8:41 // 3 relogs, i want to exclude it and only show last one.
[22:26] <SA-TDM[1]> givi.koguashvili logged in 11/06/2013 8:32
[22:26] <SA-TDM[1]> givi.koguashvili logged in 11/06/2013 8:28
[22:26] <SA-TDM[1]> Uros_Andjelkovic logged in 11/06/2013 8:27
[22:26] <SA-TDM[1]> Jonh_Henson logged in 11/06/2013 8:12
Re: MYSQL problem -
Richie© - 12.06.2013
bump
Re: MYSQL problem -
Vince - 12.06.2013
PHP код:
SELECT MAX(PlayerName), MAX(Time) FROM lol_Players GROUP BY PlayerName ORDER BY Time DESC LIMIT 10
Try that instead. I'm not too good with
group by since it tends to complain a lot about aggregate functions. Or at least it did in MSSQL.
Re: MYSQL problem -
Richie© - 12.06.2013
Vince saving the day again

Thanks!