poll.amxx ошибки с SQL

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
3,593
Реакции
1,576
Помог
141 раз(а)
Ошибка
L 06/11/2019 - 16:43:10: [AMXX] Plugin ("poll.amxx") is setting itself as failed.
L 06/11/2019 - 16:43:10: [AMXX] Plugin says: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '666 ', 'STEAM_0:0:145076814', 'На каком разрешении экран' at line 1
L 06/11/2019 - 16:43:10: [AMXX] Displaying debug trace (plugin "poll.amxx", version "1.1")
L 06/11/2019 - 16:43:10: [AMXX] Run time error 1: forced exit
L 06/11/2019 - 16:43:10: [AMXX] [0] poll.sma::main_menu_handler (line 180)
ОС
Linux
Amx Mod X
AMX Mod X 1.10.0.5252
Билд
ReHLDS version: 3.4.0.669-dev
ReGamedll
ReGameDLL version: 5.7.0.328-dev
Версия Metamod
Metamod-r v1.3.0.128, API (5:13)
Список метамодулей
Currently loaded plugins:
description stat pend file vers src load unload
[ 1] Reunion RUN - reunion_mm_i386.so v0.1.0.133 ini Start Never
[ 2] ReAuthCheck RUN - reauthcheck_mm_i386.so v0.1.6 ini Start Never
[ 3] Rechecker RUN - rechecker_mm_i386.so v2.5 ini Chlvl ANY
[ 4] Revoice RUN - revoice_mm_i386.so v0.1.0.32 ini Start Never
[ 5] AMX Mod X RUN - amxmodx_mm_i386.so v1.10.0.5252 ini Start ANY
[ 6] MySQL RUN - mysql_amxx_i386.so v1.10.0.5252 pl5 ANY ANY
[ 7] SQLite RUN - sqlite_amxx_i386.so v1.10.0.5252 pl5 ANY ANY
[ 8] Fun RUN - fun_amxx_i386.so v1.10.0.5252 pl5 ANY ANY
[ 9] Engine RUN - engine_amxx_i386.so v1.10.0.5252 pl5 ANY ANY
[10] FakeMeta RUN - fakemeta_amxx_i386.so v1.10.0.5252 pl5 ANY ANY
[11] CStrike RUN - cstrike_amxx_i386.so v1.10.0.5252 pl5 ANY ANY
[12] Ham Sandwich RUN - hamsandwich_amxx_i386.so v1.10.0.5252 pl5 ANY ANY
[13] ReAPI RUN - reapi_amxx_i386.so v5.8.0.166-dev pl5 ANY Never
[14] GeoIP RUN - geoip_amxx_i386.so v1.10.0.5252 pl5 ANY ANY

[15] whois RUN - whois_amxx_i386.so v0.2.270 pl5 ANY ANY
[16] CURL AMXX RUN - curl_amxx_i386.so v1.1.0 pl5 ANY ANY
16 plugins, 16 running
Список плагинов
Currently loaded plugins:
name version author file status
[ 1] fb_forwards 0.1.4 Kanagava & Realu fb_forwards.amx running
[ 2] WebHS 0.1 kanagava fb_web_online.a running
[ 3] FreshBans 1.4.0b kanagava fresh_bans_140_ running
[ 4] SF Warn Menu 0.1.4g_edi serfreeman1337/N sf_admin_warns. running
[ 5] CSStatsX SQL 0.7.4+1 serfreeman1337 csstatsx_sql.am running
[ 6] Rank Menu 1.1 h1k3 rankmenu.amxx running
[ 7] AES: StatsX 0.5 Vega serfreeman1337 statsx_cstrike. running
[ 8] Multi-Rendering System [ReAPI] 0. Subb98/Nordic Wa multirendering. running
[ 9] Admin Load 3.10.0 F@nt0M adminload.amxx running
[ 10] Admin Commands 1.10.0.525 AMXX Dev Team admincmd.amxx running
[ 11] Admin Help 1.10.0.525 AMXX Dev Team adminhelp.amxx running
[ 12] Menus Front-End 1.10.0.525 AMXX Dev Team menufront.amxx running
[ 13] Commands Menu 1.10.0.525 AMXX Dev Team cmdmenu.amxx running
[ 14] Players Menu 1.10.0.525 AMXX Dev Team plmenu.amxx running

[ 15] Teleport Menu 1.10.0.525 AMXX Dev Team telemenu.amxx running
[ 16] Maps Menu 1.10.0.525 AMXX Dev Team mapsmenu.amxx running
[ 17] Admin Chat 1.10.0.525 AMXX Dev Team adminchat.amxx running
[ 18] Anti Flood 1.10.0.525 AMXX Dev Team antiflood.amxx running
[ 19] Admin Votes 1.10.0.525 AMXX Dev Team adminvote.amxx running
[ 20] Pause Plugins 1.10.0.525 AMXX Dev Team pausecfg.amxx running
[ 21] Stats Configuration 1.10.0.525 AMXX Dev Team statscfg.amxx running
[ 22] unknown unknown unknown 35hp_16.amxx stopped
[ 23] AdminMenu 1.1 Nordic Warrior adminmenu.amxx running
[ 24] Admin menu central 0.2 Nordic Warrior adminmenu_centr running
[ 25] Advanced Lottery 0.5.1 Nordic Warrior advanced_lotter running
[ 26] [ReAPI] Advanced Team 0.1.0 Vaqtincha AdvancedTeamCho running
[ 27] Advert Messages 1.22 neygomon adverts.amxx running
[ 28] AFK Protection 2.3.3 rapara13/Nordic afk.amxx running
[ 29] AimInfo 2.1 xPaw/Nordic Warr aim_info.amxx running

[ 30] Ball 1.2.1 xPaw/Nordic Warr ball.amxx running
[ 31] BhopHack Detector 0.1 Mistrick bhophack_detect running
[ 32] [Reapi] Block Advert 1.4 neygomon block_advert.am running
[ 33] Bypass Guard 24.05.2019 mx?! bypass_guard_ip running
[ 34] CameraChanger Lite 0.1 Nordic Warrior camera_changer. running
[ 35] Advanced Client Checke 0.3.7e Mistrick cmdchecker.amxx running
[ 36] Connect Exec 1.1 AleX/Nordic Warr connect_exec.am running
[ 37] Chat Manager 4.4 OciXCrom crx_chatmanager running
[ 38] CM: Toggle Chat 4.1 OciXCrom crx_chatmanager running
[ 39] OciXCrom's Rank System 3.4 OciXCrom crx_ranksystem. running
[ 40] Knife Models 3.1 OciXCrom crx_knife_model running
[ 41] [ReAPI] Custom Models 1.6.1 neugomon custom_models.a running
[ 42] Demo Recorder 2.4.0 F@nt0M demo_recorder.a running
[ 43] Fix for sky 1.0 Nordic Warrior fix_maps.amxx running
[ 44] Gag System 1.1 TheRedShoko @ AM gag_system.amxx running

[ 45] GameName Changer 1.0 neugomon gamename.amxx running
[ 46] High Ping Kicker 1.0 OLO/shadow/Nordi high_ping_kicke running
[ 47] iFLY 1.0 arttty7 iFLY.amxx debug
[ 48] iHOOK 1.0 arttty7 iHOOK.amxx running
[ 49] Invisible Spectator 1.0 ReHLDS Team invisible_spect running
[ 50] Kill Distance 0.4 Nightscream/Nord kill_distance.a running
[ 51] Knife Duel Arena 1.32 bionext knife_duel_aren debug
[ 52] Knife Duel Arena Edito 1.0 bionext knife_duel_aren paused
[ 53] Knife Duel Arena Edito 0.2 Nordic Warrior knife_duel_aren running
[ 54] Knife Duel Arena Block 0.2 bionext/Nordic W knife_duel_aren running
[ 55] Language Menu 1.0 F@nt0M langmenu.amxx running
[ 56] Light Menu 0.3 Nordic Warrior light_menu.amxx running
[ 57] Mind Games 1.1 fifayer/Nordic W MindGames.amxx running
[ 58] Money System Best t3rkecorejz MoneySystem.amx running
[ 59] Mute Menu 12.02.2019 w0w/Nordic Warri mute_menu.amxx running

[ 60] New Grab 1.0 Nordic Warrior/N new_grab.amxx running
[ 61] KillStreakAnnouncer 0.3 Nordic Warrior nkillstreak.amx running
[ 62] Knife Menu 1.3 Nordic Warrior nknifemenu.amxx running
[ 63] Knife shop 0.2.1 Nordic Warrior nknifeshop.amxx running
[ 64] Online Helper 2.1.3 Nordic Warrior online_helper.a running
[ 65] Paint Marker 1.1 w0w paint_marker.am running
[ 66] [ReAPI] Parachute 1.1 ReHLDS Team parachute.amxx running
[ 67] Pingwinowa bombka 0.1 diablix pingwin.amxx running
[ 68] Poll 1.1 Nunfy poll.amxx debug
[ 69] Random Skies 1.1 rmk by N.W. randomskies.amx running
[ 70] ReChecker Logging 1.0 custom rc_logging.amxx running
[ 71] Reset Score 1.0 Nordic Warrior reset_score.amx running
[ 72] Spectator Bots 2.1 SISA spectator_bots. running
[ 73] SteamID Limiter 0.4 Mistrick steamid_limiter running
[ 74] Money Transfer 1.2 x3/Nordic Warrio tm.amxx debug

[ 75] Train Killer 1.2 Pastout!/Nordic trainkiller.amx running
[ 76] VipMenu 1.0 Nordic Warrior vipmenu.amxx running
[ 77] Yet Another Voteban 1.8 AndrewZ/voed yet_another_vot running
[ 78] Map Manager: Core 3.0.1 Mistrick map_manager_cor running
[ 79] Map Manager: Scheduler 0.1.0 Mistrick map_manager_sch running
[ 80] Map Manager: Rtv 0.0.4 Mistrick map_manager_rtv running
[ 81] Map Manager: Nominatio 0.0.8 Mistrick map_manager_nom running
[ 82] Map Manager: Online so 0.0.2 Mistrick map_manager_onl running
[ 83] Map Manager: Effects 0.0.8 Mistrick map_manager_eff running
[ 84] Map Manager: Informer 0.0.5 Mistrick map_manager_inf running
[ 85] Map Manager: Advanced 0.0.4 Mistrick map_manager_adv running
85 plugins, 83 running
Автор плагина
Nunfy
Версия плагина
1.1 с вырезанной зависимостью от CsStatsxSQL
Исходный код
Оригинал - https://dev-cs.ru/resources/574/
Код:
#include <amxmodx>
#include <reapi>
#include <util_parser>
#include <sqlx>

#define PLUGIN  "Poll"
#define VERSION "1.1"
#define AUTHOR  "Nunfy"

#define MYSQL_HOSTNAME    ""
#define MYSQL_USERNAME    ""
#define MYSQL_PASSWORD    ""
#define MYSQL_DATABASE    ""
#define MYSQL_TABLE        "table_name"

#define MAX_MENU_SIZE            512        // Максимальный размер меню
#define MAX_ITEM_LENGHT            200     // Максимальный длинна пункта меню
#define MAX_POLLS                5        // Максимальное количество опросов
#define MAX_NICKNAME_LENGHT        30         // Максимальная длинна никнейма
#define MAX_STEAM_ID_LENGHT        35         // Максимальная длинна стим ид
#define MAX_MAP_LENGHT            30         // Максимальная длинна названия карты

#define register_menu(%0,%1,%2) register_menucmd(register_menuid(%0), %1, %2)

enum user_data
{
    bool: uMenu,
    uPoll,
    bool: uAnswered
};

static     config_file_dir[] = "addons/amxmodx/configs/poll.ini"; // путь к ini файлу
new polls[MAX_POLLS][5][MAX_ITEM_LENGHT],
    polls_items[MAX_POLLS],
    ud[MAX_PLAYERS + 1][user_data];

new Handle: mysql_turple;
new Handle: mysql_connection;

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR);
    RegisterHookChain(RG_CBasePlayer_Killed, "user_killed", true);
    RegisterHookChain(RG_CSGameRules_RestartRound, "restart_round", true);
    register_menu("\r[\wОпрос\r]", 1023, "main_menu_handler");
    new file_id = UTIL_ParserLoadFile(config_file_dir);
    for(new p; p < MAX_POLLS; p++)
    {
        new string[10];
        format(string, charsmax(string), "[POLL_%d]", p);
        console_print(0, "%s", string);
        for(new i; i < UTIL_ParserGetLines(file_id, string); i++)
        {
            UTIL_ParserGetContent(file_id, i, polls[p][i], MAX_ITEM_LENGHT + 1, string);
            polls_items[p] = i;
            console_print(0, "%s", polls[p][i]);
        }
    }
    mysql_connect();
    new Handle: query = SQL_PrepareQuery(mysql_connection, "UPDATE %s SET map = ''", MYSQL_TABLE);
    if(!SQL_Execute(query))
    {
        new error[512];
        SQL_QueryError(query, error, charsmax(error));
        set_fail_state(error);
    }
    SQL_FreeHandle(query);
}

public client_putinserver(id)
{
    load_data(id);
}

public client_disconnected(id, bool:drop, message[], maxlen)
{
    ud[id][uMenu] = false;
    ud[id][uPoll] = 0;
    ud[id][uAnswered] = false;
}

public user_killed(const this, pevAttacker, iGib)
{
    if(ud[this][uAnswered] == true)
        return;

    new string[MAX_MENU_SIZE], keys = MENU_KEY_7;
    switch(polls_items[ud[this][uPoll]])
    {
        case 1:
        {
            format(string, charsmax(string), "\r[\wОпрос\r]\
            ^n^n%s\
            ^n^n\r7. \w%s",
            polls[ud[this][uPoll]][0],
            polls[ud[this][uPoll]][1]);
            keys = MENU_KEY_7;
        }
        case 2:
        {
            format(string, charsmax(string), "\r[\wОпрос\r]\
            ^n^n%s\
            ^n^n\r7. \w%s\
            ^n\r8. \w%s",
            polls[ud[this][uPoll]][0],
            polls[ud[this][uPoll]][1],
            polls[ud[this][uPoll]][2]);
            keys = MENU_KEY_7|MENU_KEY_8;
        }
        case 3:
        {
            format(string, charsmax(string), "\r[\wОпрос\r]\
            ^n^n%s\
            ^n^n\r7. \w%s\
            ^n\r8. \w%s\
            ^n\r9. \w%s",
            polls[ud[this][uPoll]][0],
            polls[ud[this][uPoll]][1],
            polls[ud[this][uPoll]][2],
            polls[ud[this][uPoll]][3]);
            keys = MENU_KEY_7|MENU_KEY_8|MENU_KEY_9;
        }
        case 4:
        {
            format(string, charsmax(string), "\r[\wОпрос\r]\
            ^n^n%s\
            ^n^n\r7. \w%s\
            ^n\r8. \w%s\
            ^n\r9. \w%s\
            ^n\r0. \w%s",
            polls[ud[this][uPoll]][0],
            polls[ud[this][uPoll]][1],
            polls[ud[this][uPoll]][2],
            polls[ud[this][uPoll]][3],
            polls[ud[this][uPoll]][4]);
            keys = MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0;
        }
    }
    ud[this][uMenu] = true;
    show_menu(this, keys, string);
}

public restart_round()
{
    new users_ids[MAX_PLAYERS], users_num;
    get_players(users_ids, users_num, "h");
    for(new i; i < users_num; i++)
    {
        if(ud[users_ids[i]][uMenu] == true)
        {
            show_menu(users_ids[i], MENU_KEY_0, "^n", 1);
        }
    }
}

public main_menu_handler(id, key)
{
    switch(key)
    {
        case 6..9:
        {
            ud[id][uAnswered] = true;
            new nickname[MAX_NICKNAME_LENGHT + 1], steam_id[MAX_STEAM_ID_LENGHT + 1], map[MAX_MAP_LENGHT + 1];
            get_user_name(id, nickname, charsmax(nickname));
            get_user_authid(id, steam_id, charsmax(steam_id));
            get_mapname(map, charsmax(map));
            new Handle: query = SQL_PrepareQuery(mysql_connection, "INSERT INTO %s (nickname, steam_id, question, answer, next_poll_id, map) \
            VALUES ('%s', '%s', '%s', '%s', '%d', '%s')",
            MYSQL_TABLE,
            nickname,
            steam_id,
            polls[ud[id][uPoll]][0],
            polls[ud[id][uPoll]][key - 5],
            ud[id][uPoll] + 1,
            map);
            if(!SQL_Execute(query))
            {
                new error[512];
                SQL_QueryError(query, error, charsmax(error));
                set_fail_state(error);
            }
            SQL_FreeHandle(query);
        }
    }
}

stock mysql_connect()
{
    new error, string[512];
    mysql_turple = SQL_MakeDbTuple(MYSQL_HOSTNAME, MYSQL_USERNAME, MYSQL_PASSWORD, MYSQL_DATABASE);
    SQL_SetCharset(mysql_turple, "utf8");
    mysql_connection = SQL_Connect(mysql_turple, error, string, charsmax(string));
    if(mysql_connection == Empty_Handle)
    {
        set_fail_state(string);
    }
}

stock load_data(id)
{
    new steam_id[MAX_STEAM_ID_LENGHT + 1];
    get_user_authid(id, steam_id, charsmax(steam_id));
    new Handle: query = SQL_PrepareQuery(mysql_connection, "SELECT * FROM %s WHERE steam_id = '%s' AND next_poll_id = (SELECT MAX(next_poll_id) FROM %s) LIMIT 1",
    MYSQL_TABLE,
    steam_id,
    MYSQL_TABLE);
    if(!SQL_Execute(query))
    {
        new error[512];
        SQL_QueryError(query, error, charsmax(error));
        set_fail_state(error);
    }
    else if(SQL_NumResults(query))
    {
        ud[id][uPoll] = SQL_ReadResult(query, 5);
        new map[MAX_MAP_LENGHT + 1];
        get_mapname(map, charsmax(map));
        query = SQL_PrepareQuery(mysql_connection, "SELECT * FROM %s WHERE steam_id = '%s' AND map = '%s' LIMIT 1",
        MYSQL_TABLE,
        steam_id,
        map);
        if(!SQL_Execute(query))
        {
            new error[512];
            SQL_QueryError(query, error, charsmax(error));
            set_fail_state(error);
        }
        else if(SQL_NumResults(query))
        {
            ud[id][uAnswered] = true;
        }
    }
    SQL_FreeHandle(query);
}

Код:
[POLL_0]
На каком разрешении экрана вы играете?
640x480
800x600
1024x768
Больше, чем эти
[POLL_1]
Как Вы узнали о нашем сервере?
От друзей
С мониторингов
Во вкладке интернет
 
В этой теме было размещено решение! Перейти к решению.
Сообщения
3,593
Реакции
1,576
Помог
141 раз(а)
Ещё заметил, что не работает функция запоминания игрока, то есть один вопрос задается всем игрокам каждый раз
 
Сообщения
673
Реакции
242
Помог
11 раз(а)
Я так понимаю таблица не создается автоматический? вышли структуру таблицы, возможно у вас некорректно создалась таблица, и на будущее, лучше запрос открывать в начале запуска карты и закрывать при смене карты, то есть SQL_Result хранить в ячейки, и дальше по ним работать
13 Июн 2019
попробуй в ручную вписать данные

$sql="INSERT INTO table_name (nickname, steam_id, question, answer, next_poll_id, map) VALUES ('Иванов', 'STEAM_123123', 'Вопрос', 'Ответ', '1', 'de_dust2')";
 
Сообщения
957
Реакции
1,185
Помог
52 раз(а)
Нет экранирования спецсимволов в данных перед вставкой. Оттуда и ноги растут.
 
Сообщения
2,491
Реакции
2,794
Помог
61 раз(а)
Сообщения
3,593
Реакции
1,576
Помог
141 раз(а)
Всем спасибо, проблема решена экранированием запросов.
 
Статус
В этой теме нельзя размещать новые ответы.

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу