MySQL crash
#1

Resulting in a server crash. I realize that the specifiers are making problem but I don't know any other way to do it..?

PHP Code:
mysql_format(Databasequerysizeof(query), "SELECT * FROM BanData WHERE IPAddress LIKE '%%s%' ORDER BY BannedOn DESC LIMIT 5"targetip); 
MySQL R41-2
Errors:
Quote:

[03/17/18 07:19:55] [plugins/mysql] mysql_format: invalid format specifier '%O'
[03/17/18 07:19:55] [plugins/mysql] error #1065 while executing query "": Query was empty
[03/17/18 07:19:55] [plugins/mysql] cache_get_row_count: no active cache
[03/17/18 07:19:55] [plugins/mysql] cache_delete: invalid cache id '0'
[03/17/18 07:19:55] [log-core] signal 11 (SIGSEGV) catched; shutting log-core down (errno: 0, signal code: 1, exit status: -251144200)

Warnings:
Quote:

[03/17/18 07:19:55] [ERROR] mysql_format: invalid format specifier '%O'
[03/17/18 07:19:55] [ERROR] error #1065 while executing query "": Query was empty
[03/17/18 07:19:55] [ERROR] cache_get_row_count: no active cache
[03/17/18 07:19:55] [ERROR] cache_delete: invalid cache id '0'

Reply
#2

Try this

PHP Code:
mysql_format(Databasequerysizeof(query), "SELECT * FROM BanData WHERE IPAddress LIKE '%%%s%%' ORDER BY BannedOn DESC LIMIT 5"targetip); 
Reply
#3

Quote:
Originally Posted by Nubik
View Post
Try this

PHP Code:
mysql_format(Databasequerysizeof(query), "SELECT * FROM BanData WHERE IPAddress LIKE '%%%s%%' ORDER BY BannedOn DESC LIMIT 5"targetip); 
Still crashing :/
Reply
#4

bump!
Reply
#5

Code:
 mysql_format(Database, query, sizeof(query), "SELECT * FROM BanData WHERE IPAddress LIKE '%%s%' ORDER BY BannedOn DESC LIMIT 5;", targetip);
Reply
#6

Quote:
Originally Posted by UFF
View Post
Code:
 mysql_format(Database, query, sizeof(query), "SELECT * FROM BanData WHERE IPAddress LIKE '%%s%' ORDER BY BannedOn DESC LIMIT 5;", targetip);
Still resulting in a server crash
Reply
#7

This format doesn't make me crash:
Code:
'%%%s%%'
mysql_format(Database, query, sizeof(query), "SELECT * FROM BanData WHERE IPAddress LIKE '%%%s%%' ORDER BY BannedOn DESC LIMIT 5;", targetip);
If the problem still occur, please post some logs.
Reply
#8

Quote:
Originally Posted by Dayrion
View Post
This format doesn't make me crash:
Code:
'%%%s%%'
mysql_format(Database, query, sizeof(query), "SELECT * FROM BanData WHERE IPAddress LIKE '%%%s%%' ORDER BY BannedOn DESC LIMIT 5;", targetip);
If the problem still occur, please post some logs.
Yes, it's still happening

I didn't get any logs now
Here's the command:
PHP Code:
CMD:searchbanip(playeridparams[])
{
    if(
LoggedIn[playerid] == false) return SendClientMessage(playeridCOLOR_RED"ERROR: You must be logged in.");
    if(
PlayerInfo[playerid][AdminLevel] < 2) return SendClientMessage(playeridCOLOR_RED"ERROR: Admin level 2+ command.");
    new 
targetip;
    if(
sscanf(params"s[24]"targetip)) return SendClientMessage(playeridCOLOR_RED"USAGE: /searchbanip [IP range]");
    new 
query[256], info[128], string[700], User[24], BannedBy[24], BanReason[40], BannedOn[30], ExpiresOn[30], IPAddress[30], GPCI[130];
    
mysql_format(Databasequerysizeof(query), "SELECT * FROM BanData WHERE IPAddress LIKE '%%%s%%' ORDER BY BannedOn DESC LIMIT 5;"targetip);
    new 
Cache:result mysql_query(Databasequery);
    if(
cache_num_rows() != 0)
    {
          
format(infosizeof(info), "{FF0000}There are bans found under the IP range you provided!{FFFFFF}\n{FEFE22}Displaying 5 latest:{FFFFFF}\n\n");
        
strcat(stringinfo);
        for(new 
0cache_num_rows(); i++)
        {
            
cache_get_value_name(i"User"UserMAX_PLAYER_NAME);
            
cache_get_value_name(i"BannedBy"BannedByMAX_PLAYER_NAME);
            
cache_get_value_name(i"BanReason"BanReason40);
            
cache_get_value_name(i"IPAddress"IPAddress16);
            
cache_get_value_name(i"BannedOn"BannedOn30);
            
cache_get_value_name(i"ExpiresOn"ExpiresOn30);
            
cache_get_value_name(i"GPCI"GPCI130);
              
format(infosizeof(info), "{FF0000}User: {FFFFFF}%s\n{FF0000}Banned by: {FFFFFF}%s\n{FF0000}Ban reason: {FFFFFF}%s\n{FF0000}IP Address: {FFFFFF}%s\n{FF0000}Banned on: {FFFFFF}%s\n{FF0000}Expires on: {FFFFFF}%s\n{FF0000}GPCI: {FFFFFF}%s\n\n"UserBannedByBanReasonIPAddressBannedOnExpiresOnGPCI);
            
strcat(stringinfo);
        }
    }
    else
    {
          
format(infosizeof(info), "There are no bans found under the IP range you specified.");
        
strcat(stringinfo);
    }
    
cache_delete(result);
    
ShowPlayerDialog(playeridDIALOG_SEARCH_BAN_IPDIALOG_STYLE_MSGBOX"Ban lookup"string"Close","");
    new 
achat[128];
    
format(achatsizeof(achat), "%s has searched bans under IP range '%s'."GetName(playerid), targetip);
    
addChatMessage(achat"blue");
    return 
1;

Reply
#9

What do you mean, there is no logs? There is always logs, even debug logs.
You shouldn't use mysql_query until you really need it or you what you do. You can use mysql_tquery instead. I added debug messages to be sure what happens. Please show those debugs messages.
PHP Code:
CMD:searchbanip(playeridparams[]) 

    if(
LoggedIn[playerid] == false) return SendClientMessage(playeridCOLOR_RED"ERROR: You must be logged in."); 
    if(
PlayerInfo[playerid][AdminLevel] < 2) return SendClientMessage(playeridCOLOR_RED"ERROR: Admin level 2+ command."); 
    new 
targetip
    if(
sscanf(params"s[24]"targetip)) return SendClientMessage(playeridCOLOR_RED"USAGE: /searchbanip [IP range]"); 
    new 
achat[128]; 
    
mysql_format(Databasequerysizeof(query), "SELECT * FROM BanData WHERE IPAddress LIKE '%%%e%%' ORDER BY BannedOn DESC LIMIT 5;"targetip);
    
printf("Query formatted: -> '%s'"query);
    
mysql_tquery(Databasequery"DisplayingBanPerIP"); 
    
format(achatsizeof(achat), "%s has searched bans under IP range '%s'."GetName(playerid), targetip); 
    
addChatMessage(achat"blue"); 
    return 
1
}  
forward DisplayingBanPerIP();
public 
DisplayingBanPerIP()
{
    print(
"Beginning 'DisplayingBanPerIP' - Rows: %i"cache_num_rows());
    new 
query[256], info[128], string[700], User[24], BannedBy[24], BanReason[40], BannedOn[30], ExpiresOn[30], IPAddress[30], GPCI[130]; 
    if(
cache_num_rows() != 0
    { 
        
format(infosizeof(info), "{FF0000}There are bans found under the IP range you provided!{FFFFFF}\n{FEFE22}Displaying 5 latest:{FFFFFF}\n\n"); 
        
strcat(stringinfo); 
        for(new 
0cache_num_rows(); i++) 
        { 
            
cache_get_value_name(i"User"UserMAX_PLAYER_NAME); 
            
cache_get_value_name(i"BannedBy"BannedByMAX_PLAYER_NAME); 
            
cache_get_value_name(i"BanReason"BanReason40); 
            
cache_get_value_name(i"IPAddress"IPAddress16); 
            
cache_get_value_name(i"BannedOn"BannedOn30); 
            
cache_get_value_name(i"ExpiresOn"ExpiresOn30); 
            
cache_get_value_name(i"GPCI"GPCI130); 
            
format(infosizeof(info), "{FF0000}User: {FFFFFF}%s\n{FF0000}Banned by: {FFFFFF}%s\n{FF0000}Ban reason: {FFFFFF}%s\n{FF0000}IP Address: {FFFFFF}%s\n{FF0000}Banned on: {FFFFFF}%s\n{FF0000}Expires on: {FFFFFF}%s\n{FF0000}GPCI: {FFFFFF}%s\n\n"UserBannedByBanReasonIPAddressBannedOnExpiresOnGPCI); 
            
strcat(stringinfo); 
        } 
    } 
    else 
    { 
        
format(infosizeof(info), "There are no bans found under the IP range you specified."); 
        
strcat(stringinfo); 
    } 
    
ShowPlayerDialog(playeridDIALOG_SEARCH_BAN_IPDIALOG_STYLE_MSGBOX"Ban lookup"string"Close",""); 
    return 
1;

Reply
#10

Thanks for the reply.
Can you tell me why threaded query is better than normal query and how can I know which to use and when?

Server still crashes.
I deleted MySQL log files before using the command in case there were old ones so I can know, but it doesn't re-create.
However, take a look at server log:

PHP Code:
[20:19:42Number of vehicle models15
[20:19:43] [debugRun time error 4"Array index out of bounds"
[20:19:43] [debug]  Attempted to read/write array element at index 65535 in array of size 1000
[20:19:43] [debugAMX backtrace:
[
20:19:43] [debug#0 00024304 in public OnPlayerTakeDamage (0, 65535, 1079194420, 54, 3) from LSCnR.amx
[20:19:54Query formatted: -> 'SELECT * FROM BanData WHERE IPAddress LIKE '%87.%' ORDER BY BannedOn DESC LIMIT 5;'
[20:19:54] [debugServer crashed while executing LSCnR.amx
[20:19:54] [debugAMX backtrace:
[
20:19:54] [debug#0 0000002e in ?? () from LSCnR.amx
[20:19:54] [debug#1 0000002e in public cmd_searchbanip () from LSCnR.amx
[20:19:54] [debug#2 native CallLocalFunction () from sampsvr-port_1956
[20:19:54] [debug#3 000006b0 in public OnPlayerCommandText (0, 2082852) from LSCnR.amx 
I had to modify your code a bit because some variables should be in the command and vice versa, here's how it looks now:
+ printf in a callback is giving a warning: warning 202: number of arguments does not match definition, so i marked it as a comment
PHP Code:
CMD:searchbanip(playeridparams[])
{
    if(
LoggedIn[playerid] == false) return SendClientMessage(playeridCOLOR_RED"ERROR: You must be logged in.");
    if(
PlayerInfo[playerid][AdminLevel] < 2) return SendClientMessage(playeridCOLOR_RED"ERROR: Admin level 2+ command.");
    new 
targetip;
    if(
sscanf(params"s[24]"targetip)) return SendClientMessage(playeridCOLOR_RED"USAGE: /searchbanip [IP range]");
    new 
achat[128], query[256];
    
mysql_format(Databasequerysizeof(query), "SELECT * FROM BanData WHERE IPAddress LIKE '%%%e%%' ORDER BY BannedOn DESC LIMIT 5;"targetip);
    
printf("Query formatted: -> '%s'"query);
    
mysql_tquery(Databasequery"DisplayingBanPerIP");
    
format(achatsizeof(achat), "%s has searched bans under IP range '%s'."GetName(playerid), targetip);
    
addChatMessage(achat"blue");
    return 
1;
}
forward DisplayingBanPerIP(playerid);
public 
DisplayingBanPerIP(playerid)
{
    
//print("Beginning 'DisplayingBanPerIP' - Rows: %i", cache_num_rows());
    
new info[128], string[700], User[24], BannedBy[24], BanReason[40], BannedOn[30], ExpiresOn[30], IPAddress[30], GPCI[130];
    if(
cache_num_rows() != 0)
    {
        
format(infosizeof(info), "{FF0000}There are bans found under the IP range you provided!{FFFFFF}\n{FEFE22}Displaying 5 latest:{FFFFFF}\n\n");
        
strcat(stringinfo);
        for(new 
0cache_num_rows(); i++)
        {
            
cache_get_value_name(i"User"UserMAX_PLAYER_NAME);
            
cache_get_value_name(i"BannedBy"BannedByMAX_PLAYER_NAME);
            
cache_get_value_name(i"BanReason"BanReason40);
            
cache_get_value_name(i"IPAddress"IPAddress16);
            
cache_get_value_name(i"BannedOn"BannedOn30);
            
cache_get_value_name(i"ExpiresOn"ExpiresOn30);
            
cache_get_value_name(i"GPCI"GPCI130);
            
format(infosizeof(info), "{FF0000}User: {FFFFFF}%s\n{FF0000}Banned by: {FFFFFF}%s\n{FF0000}Ban reason: {FFFFFF}%s\n{FF0000}IP Address: {FFFFFF}%s\n{FF0000}Banned on: {FFFFFF}%s\n{FF0000}Expires on: {FFFFFF}%s\n{FF0000}GPCI: {FFFFFF}%s\n\n"UserBannedByBanReasonIPAddressBannedOnExpiresOnGPCI);
            
strcat(stringinfo);
        }
    }
    else
    {
        
format(infosizeof(info), "There are no bans found under the IP range you specified.");
        
strcat(stringinfo);
    }
    
ShowPlayerDialog(playeridDIALOG_SEARCH_BAN_IPDIALOG_STYLE_MSGBOX"Ban lookup"string"Close","");
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)