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(Database, query, sizeof(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(Database, query, sizeof(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(Database, query, sizeof(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(playerid, params[])
{
    if(
LoggedIn[playerid] == false) return SendClientMessage(playerid, COLOR_RED, "ERROR: You must be logged in.");
    if(
PlayerInfo[playerid][AdminLevel] < 2) return SendClientMessage(playerid, COLOR_RED, "ERROR: Admin level 2+ command.");
    new 
targetip;
    if(
sscanf(params, "s[24]", targetip)) return SendClientMessage(playerid, COLOR_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(Database, query, sizeof(query), "SELECT * FROM BanData WHERE IPAddress LIKE '%%%s%%' ORDER BY BannedOn DESC LIMIT 5;", targetip);
    new 
Cache:result = mysql_query(Database, query);
    if(
cache_num_rows() != 0)
    {
          
format(info, sizeof(info), "{FF0000}There are bans found under the IP range you provided!{FFFFFF}\n{FEFE22}Displaying 5 latest:{FFFFFF}\n\n");
        
strcat(string, info);
        for(new 
i = 0; i < cache_num_rows(); i++)
        {
            
cache_get_value_name(i, "User", User, MAX_PLAYER_NAME);
            
cache_get_value_name(i, "BannedBy", BannedBy, MAX_PLAYER_NAME);
            
cache_get_value_name(i, "BanReason", BanReason, 40);
            
cache_get_value_name(i, "IPAddress", IPAddress, 16);
            
cache_get_value_name(i, "BannedOn", BannedOn, 30);
            
cache_get_value_name(i, "ExpiresOn", ExpiresOn, 30);
            
cache_get_value_name(i, "GPCI", GPCI, 130);
              
format(info, sizeof(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", User, BannedBy, BanReason, IPAddress, BannedOn, ExpiresOn, GPCI);
            
strcat(string, info);
        }
    }
    else
    {
          
format(info, sizeof(info), "There are no bans found under the IP range you specified.");
        
strcat(string, info);
    }
    
cache_delete(result);
    
ShowPlayerDialog(playerid, DIALOG_SEARCH_BAN_IP, DIALOG_STYLE_MSGBOX, "Ban lookup", string, "Close","");
    new 
achat[128];
    
format(achat, sizeof(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(playerid, params[]) 
{ 
    if(
LoggedIn[playerid] == false) return SendClientMessage(playerid, COLOR_RED, "ERROR: You must be logged in."); 
    if(
PlayerInfo[playerid][AdminLevel] < 2) return SendClientMessage(playerid, COLOR_RED, "ERROR: Admin level 2+ command."); 
    new 
targetip; 
    if(
sscanf(params, "s[24]", targetip)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /searchbanip [IP range]"); 
    new 
achat[128]; 
    
mysql_format(Database, query, sizeof(query), "SELECT * FROM BanData WHERE IPAddress LIKE '%%%e%%' ORDER BY BannedOn DESC LIMIT 5;", targetip);
    
printf("Query formatted: -> '%s'", query);
    
mysql_tquery(Database, query, "DisplayingBanPerIP"); 
    
format(achat, sizeof(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(info, sizeof(info), "{FF0000}There are bans found under the IP range you provided!{FFFFFF}\n{FEFE22}Displaying 5 latest:{FFFFFF}\n\n"); 
        
strcat(string, info); 
        for(new 
i = 0; i < cache_num_rows(); i++) 
        { 
            
cache_get_value_name(i, "User", User, MAX_PLAYER_NAME); 
            
cache_get_value_name(i, "BannedBy", BannedBy, MAX_PLAYER_NAME); 
            
cache_get_value_name(i, "BanReason", BanReason, 40); 
            
cache_get_value_name(i, "IPAddress", IPAddress, 16); 
            
cache_get_value_name(i, "BannedOn", BannedOn, 30); 
            
cache_get_value_name(i, "ExpiresOn", ExpiresOn, 30); 
            
cache_get_value_name(i, "GPCI", GPCI, 130); 
            
format(info, sizeof(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", User, BannedBy, BanReason, IPAddress, BannedOn, ExpiresOn, GPCI); 
            
strcat(string, info); 
        } 
    } 
    else 
    { 
        
format(info, sizeof(info), "There are no bans found under the IP range you specified."); 
        
strcat(string, info); 
    } 
    
ShowPlayerDialog(playerid, DIALOG_SEARCH_BAN_IP, DIALOG_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:42] Number of vehicle models: 15
[20:19:43] [debug] Run 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] [debug] AMX backtrace:
[
20:19:43] [debug] #0 00024304 in public OnPlayerTakeDamage (0, 65535, 1079194420, 54, 3) from LSCnR.amx
[20:19:54] Query formatted: -> 'SELECT * FROM BanData WHERE IPAddress LIKE '%87.%' ORDER BY BannedOn DESC LIMIT 5;'
[20:19:54] [debug] Server crashed while executing LSCnR.amx
[20:19:54] [debug] AMX 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(playerid, params[])
{
    if(
LoggedIn[playerid] == false) return SendClientMessage(playerid, COLOR_RED, "ERROR: You must be logged in.");
    if(
PlayerInfo[playerid][AdminLevel] < 2) return SendClientMessage(playerid, COLOR_RED, "ERROR: Admin level 2+ command.");
    new 
targetip;
    if(
sscanf(params, "s[24]", targetip)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /searchbanip [IP range]");
    new 
achat[128], query[256];
    
mysql_format(Database, query, sizeof(query), "SELECT * FROM BanData WHERE IPAddress LIKE '%%%e%%' ORDER BY BannedOn DESC LIMIT 5;", targetip);
    
printf("Query formatted: -> '%s'", query);
    
mysql_tquery(Database, query, "DisplayingBanPerIP");
    
format(achat, sizeof(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(info, sizeof(info), "{FF0000}There are bans found under the IP range you provided!{FFFFFF}\n{FEFE22}Displaying 5 latest:{FFFFFF}\n\n");
        
strcat(string, info);
        for(new 
i = 0; i < cache_num_rows(); i++)
        {
            
cache_get_value_name(i, "User", User, MAX_PLAYER_NAME);
            
cache_get_value_name(i, "BannedBy", BannedBy, MAX_PLAYER_NAME);
            
cache_get_value_name(i, "BanReason", BanReason, 40);
            
cache_get_value_name(i, "IPAddress", IPAddress, 16);
            
cache_get_value_name(i, "BannedOn", BannedOn, 30);
            
cache_get_value_name(i, "ExpiresOn", ExpiresOn, 30);
            
cache_get_value_name(i, "GPCI", GPCI, 130);
            
format(info, sizeof(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", User, BannedBy, BanReason, IPAddress, BannedOn, ExpiresOn, GPCI);
            
strcat(string, info);
        }
    }
    else
    {
        
format(info, sizeof(info), "There are no bans found under the IP range you specified.");
        
strcat(string, info);
    }
    
ShowPlayerDialog(playerid, DIALOG_SEARCH_BAN_IP, DIALOG_STYLE_MSGBOX, "Ban lookup", string, "Close","");
    return 
1;
} 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)