Query was empty - 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: Query was empty (
/showthread.php?tid=634649)
Query was empty -
FaLLenGirL - 23.05.2017
Hello there i have a problem with this query.
When a player join the server the system will
check automatically if he/she is banned or not.
So the problem is that now, when a player join the
server in my server-log.txt appears this error:
PHP код:
[OnQueryError (1065, Query was empty, BanListCheck)]
BanListCheck function:
PHP код:
function BanListCheck( playerid )
{
eString[ 0 ] = EOS;
new count_rows, bField[ 4 ][ 512 ], query[ 1000 ], Days[ 4 ];
cache_get_row_count( count_rows );
if( count_rows )
{
cache_get_value_int( 0, "BanExpire", Days[ 0 ] );
cache_get_value_name( 0, "Reason", bField[ 0 ] );
cache_get_value_name( 0, "Admin", bField[ 1 ] );
cache_get_value_name( 0, "BanDate", bField[ 2 ] );
cache_get_value_name( 0, "BanTime", bField[ 3 ] );
Days[ 1 ] = gettime( );
Days[ 2 ] = Days[ 0 ] - Days[ 1 ];
Days[ 3 ] = floatround( ( ( Days[ 2 ] / 24 ) /60 ) / 60 );
if( Days[ 0 ] == -1 )
{
for( new i = 0; i < 30; i ++ )
SendClientMessage( playerid, ~1, " " );
format( eString, sizeof( eString ), "{FF1C1C}You are banned on this server !\n\n{FFFFFF}Nickname: {41C63F}%s\n\n{FFFFFF}IP: {D6D6D6}%s\n\n{FFFFFF}Banned by: {FF1C1C}%s\n\n{FFFFFF}Reason: {41C63F}%s\n\n\
{FFFFFF}Ban Date: {41C63F}%s\n\n{FFFFFF}Ban Time: {41C63F}%s\n\n{FFFFFF}Ban Days: {41C63F}Permanent\n\n{FFFFFF}If you want to get unbanned visit {FF1C1C}<< www.hype-zone.ro >>\n{FF1C1C}** {FFFFFF}Take a screenshot to this dialog.", PlayerName( playerid ), GetPlayerIPEx( playerid ), bField[ 1 ], bField[ 0 ], bField[ 2 ], bField[ 3 ] );
ShowPlayerDialog( playerid, DIALOG_COMMON, DIALOG_STYLE_MSGBOX, "{FFFFFF}Ban Details:", eString, "OK", "");
KickEx( playerid );
}
else if( gettime( ) >= Days[ 0 ] )
{
mysql_format( database, query, sizeof( query ), "UPDATE `Bans` SET `BanExpire` = '0' WHERE `Name` = '%s'", PlayerName( playerid ) );
mysql_tquery( database, query, "", "" );
}
else if( Days[ 3 ] > 0 )
{
for( new i = 0; i < 30; i ++ )
SendClientMessage( playerid, ~1, " " );
format( eString, sizeof( eString ), "{FF1C1C}You are banned on this server !\n\n{FFFFFF}Nickname: {41C63F}%s\n\n{FFFFFF}IP: {D6D6D6}%s\n\n{FFFFFF}Banned by: {FF1C1C}%s\n\n{FFFFFF}Reason: {41C63F}%s\n\n\
{FFFFFF}Ban Date: {41C63F}%s\n\n{FFFFFF}Ban Time: {41C63F}%s\n\n{FFFFFF}Banned for: {41C63F}%d day(s)\n\n\
{FFFFFF}If you want to get unbanned visit {FF1C1C}<< www.hype-zone.ro >>\n{FF1C1C}** {FFFFFF}Take a screenshot to this dialog.", PlayerName( playerid ), GetPlayerIPEx( playerid ), bField[ 1 ], bField[ 0 ], bField[ 2 ], bField[ 3 ], Days[ 3 ]);
ShowPlayerDialog( playerid, DIALOG_COMMON, DIALOG_STYLE_MSGBOX, "{FFFFFF}Ban Details:", eString, "OK", "");
KickEx( playerid );
}
}
return 1;
}
This function is called at OnPlayerConnect public, just here:
PHP код:
public OnPlayerConnect( playerid )
{
new conn_ip[ 16 ];
GetPlayerIp( playerid, conn_ip, 16 );
new query[ 1000 ];
mysql_format( database, query, sizeof( query ), "SELECT * FROM `Bans` WHERE `IP` LIKE '%%%s%%%' OR `Name` = '%s'", conn_ip, PlayerName( playerid ) );
mysql_tquery( database, query, "BanListCheck", "i", playerid );
.
.
.
bla bla
return 1;
}
I don't know how to fix this. If you can help me please reply.
I am using:
MySQL R41-2.
Re: Query was empty -
FaLLenGirL - 23.05.2017
Bump
Re: Query was empty -
FaLLenGirL - 24.05.2017
Someone ? I need to fix that.. please help.
Re: Query was empty -
Cadilab - 24.05.2017
?
And why are you using LIKE for this ?
Like will check if there are names or ips similar to the ones you are looking for.
Try this
pawn Код:
SELECT * FROM Bans WHERE IP='%e' OR Name='%e' LIMIT 1
and please provide log file if this doesn't resolve the issue.
and for the further usage use %e instead of %s parameter while formating a query, it's safer.
Re: Query was empty -
jlalt - 24.05.2017
only need two in last ->
also print your querys to see if they contain anything
PHP код:
public OnPlayerConnect( playerid )
{
new conn_ip[ 16 ];
GetPlayerIp( playerid, conn_ip, 16 );
new query[ 1000 ];
mysql_format( database, query, sizeof( query ), "SELECT * FROM `Bans` WHERE `IP` LIKE '%%%s%%' OR `Name` = '%s'", conn_ip, PlayerName( playerid ) );
printf("Query1: %s",query);
mysql_tquery( database, query, "BanListCheck", "i", playerid );
.
.
.
bla bla
return 1;
}
PHP код:
function BanListCheck( playerid )
{
eString[ 0 ] = EOS;
new count_rows, bField[ 4 ][ 512 ], query[ 1000 ], Days[ 4 ];
cache_get_row_count( count_rows );
if( count_rows )
{
cache_get_value_int( 0, "BanExpire", Days[ 0 ] );
cache_get_value_name( 0, "Reason", bField[ 0 ] );
cache_get_value_name( 0, "Admin", bField[ 1 ] );
cache_get_value_name( 0, "BanDate", bField[ 2 ] );
cache_get_value_name( 0, "BanTime", bField[ 3 ] );
Days[ 1 ] = gettime( );
Days[ 2 ] = Days[ 0 ] - Days[ 1 ];
Days[ 3 ] = floatround( ( ( Days[ 2 ] / 24 ) /60 ) / 60 );
if( Days[ 0 ] == -1 )
{
for( new i = 0; i < 30; i ++ )
SendClientMessage( playerid, ~1, " " );
format( eString, sizeof( eString ), "{FF1C1C}You are banned on this server !\n\n{FFFFFF}Nickname: {41C63F}%s\n\n{FFFFFF}IP: {D6D6D6}%s\n\n{FFFFFF}Banned by: {FF1C1C}%s\n\n{FFFFFF}Reason: {41C63F}%s\n\n\
{FFFFFF}Ban Date: {41C63F}%s\n\n{FFFFFF}Ban Time: {41C63F}%s\n\n{FFFFFF}Ban Days: {41C63F}Permanent\n\n{FFFFFF}If you want to get unbanned visit {FF1C1C}<< www.hype-zone.ro >>\n{FF1C1C}** {FFFFFF}Take a screenshot to this dialog.", PlayerName( playerid ), GetPlayerIPEx( playerid ), bField[ 1 ], bField[ 0 ], bField[ 2 ], bField[ 3 ] );
ShowPlayerDialog( playerid, DIALOG_COMMON, DIALOG_STYLE_MSGBOX, "{FFFFFF}Ban Details:", eString, "OK", "");
KickEx( playerid );
}
else if( gettime( ) >= Days[ 0 ] )
{
mysql_format( database, query, sizeof( query ), "UPDATE `Bans` SET `BanExpire` = '0' WHERE `Name` = '%s'", PlayerName( playerid ) );
printf("Query 2: %s",query);
mysql_tquery( database, query, "", "" );
}
else if( Days[ 3 ] > 0 )
{
for( new i = 0; i < 30; i ++ )
SendClientMessage( playerid, ~1, " " );
format( eString, sizeof( eString ), "{FF1C1C}You are banned on this server !\n\n{FFFFFF}Nickname: {41C63F}%s\n\n{FFFFFF}IP: {D6D6D6}%s\n\n{FFFFFF}Banned by: {FF1C1C}%s\n\n{FFFFFF}Reason: {41C63F}%s\n\n\
{FFFFFF}Ban Date: {41C63F}%s\n\n{FFFFFF}Ban Time: {41C63F}%s\n\n{FFFFFF}Banned for: {41C63F}%d day(s)\n\n\
{FFFFFF}If you want to get unbanned visit {FF1C1C}<< www.hype-zone.ro >>\n{FF1C1C}** {FFFFFF}Take a screenshot to this dialog.", PlayerName( playerid ), GetPlayerIPEx( playerid ), bField[ 1 ], bField[ 0 ], bField[ 2 ], bField[ 3 ], Days[ 3 ]);
ShowPlayerDialog( playerid, DIALOG_COMMON, DIALOG_STYLE_MSGBOX, "{FFFFFF}Ban Details:", eString, "OK", "");
KickEx( playerid );
}
}
return 1;
}
Re: Query was empty -
Sew_Sumi - 24.05.2017
24 hour bumps only as well.
Re: Query was empty -
FaLLenGirL - 24.05.2017
Solved. Thank your guys.