SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 17/03/2018, 06:26 AM   #1
C5Perfect
Little Clucker
 
Join Date: May 2016
Posts: 36
Reputation: 1
Default MySQL crash

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'
__________________
C5Perfect is offline   Reply With Quote
Old 17/03/2018, 08:39 AM   #2
Nubik
Big Clucker
 
Nubik's Avatar
 
Join Date: May 2013
Location: $location
Posts: 52
Reputation: 4
Default Re: MySQL crash

Try this

PHP Code:
mysql_format(Databasequerysizeof(query), "SELECT * FROM BanData WHERE IPAddress LIKE '%%%s%%' ORDER BY BannedOn DESC LIMIT 5"targetip); 
Nubik is offline   Reply With Quote
Old 17/03/2018, 09:08 AM   #3
C5Perfect
Little Clucker
 
Join Date: May 2016
Posts: 36
Reputation: 1
Default Re: MySQL crash

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 :/
__________________
C5Perfect is offline   Reply With Quote
Old 18/03/2018, 09:41 AM   #4
kovac
Banned
 
Join Date: Mar 2018
Posts: 177
Reputation: 14
Default Re: MySQL crash

bump!
kovac is offline   Reply With Quote
Old 18/03/2018, 05:21 PM   #5
UFF
Banned
 
Join Date: Feb 2018
Location: Funky World
Posts: 346
Reputation: 28
Default Re: MySQL crash

Code:
 mysql_format(Database, query, sizeof(query), "SELECT * FROM BanData WHERE IPAddress LIKE '%%s%' ORDER BY BannedOn DESC LIMIT 5;", targetip);
UFF is offline   Reply With Quote
Old 19/03/2018, 09:43 PM   #6
kovac
Banned
 
Join Date: Mar 2018
Posts: 177
Reputation: 14
Default Re: MySQL crash

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
kovac is offline   Reply With Quote
Old 19/03/2018, 11:17 PM   #7
Dayrion
High-roller
 
Dayrion's Avatar
 
Join Date: Jan 2016
Location: France
Posts: 1,915
Reputation: 258
Default Re: MySQL crash

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.
__________________
actor_plus - v5.0.2
I'm a goner, somebody catch my breath,
I'm a goner, somebody catch my breath
Dayrion is offline   Reply With Quote
Old 20/03/2018, 12:23 PM   #8
kovac
Banned
 
Join Date: Mar 2018
Posts: 177
Reputation: 14
Default Re: MySQL crash

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;

kovac is offline   Reply With Quote
Old 20/03/2018, 06:22 PM   #9
Dayrion
High-roller
 
Dayrion's Avatar
 
Join Date: Jan 2016
Location: France
Posts: 1,915
Reputation: 258
Default Re: MySQL crash

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;

__________________
actor_plus - v5.0.2
I'm a goner, somebody catch my breath,
I'm a goner, somebody catch my breath
Dayrion is offline   Reply With Quote
Old 20/03/2018, 07:32 PM   #10
kovac
Banned
 
Join Date: Mar 2018
Posts: 177
Reputation: 14
Default Re: MySQL crash

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;

kovac is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL Crash icra Scripting Help 3 23/04/2015 02:19 AM
MySQL Crash ahmedkoki Scripting Help 6 22/02/2014 08:11 PM
MySql Crash Shirley Scripting Help 2 08/09/2013 07:01 AM
MySQL R7 Crash Sp3cter Scripting Help 0 21/07/2013 12:57 PM


All times are GMT. The time now is 02:37 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.