skript-db MySQL issues

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

DavivaD

Member
Jan 11, 2018
1
0
0
23
I was wrote a MySQL Report system using skript-db and skUtilities with connect checking...
code_language.skript:
# MultiGameReportSystem
# Autor: DavivaD
# Opis: Skript po poprawnym /zglos wysyła informację o zgłoszeniu do bazy danych MySQL do wyświetlenia ich na stronie WWW ###
# Wymagane moduły: skript-db, skUtilities

# OPCJE
options:
    # BAZA DANYCH
    host: hosting.pukawka.pl               # Adres Bazy
    port: 3306               # Port Bazy (Domyślnie: 3306)
    user: thecich_677352               # Login
    pass: *****               # Hasło
    db: 677352               # Nazwa Bazy
    table: mgrs               # Prefiks Tabeli (Domyślnie: mgrs)
    # ZGŁOSZENIE
    game: mc               # Typ Gry (Domyślnie: mc)
    server: <span style=""color: red;"">1.11.2</span> Survival+Gildie           # Wyświetlana nazwa Serwera (HTML Dozwolone)
    # CHAT
    prefix: &8[&9Zgłoszenie&8]           # Prefiks Wiadomości (Domyślnie: [MGRS])
    messagecolor: &f       # Kolor Wiadomości (Domyślnie: &f)
    errorcolor: &c           # Kolor Błędu (Domyślnie: &c)
    infocolor: &a           # Kolor Informacji (Domyślnie: &a)
    accentcolor: &9   # Akcentowany Kolor
    command: mgrs       # Nazwa Komendy (Domyślnie: mgrs)
  
on script load:
    set {output::*} to "<none>"
    set {sql} to the database "mysql://{@host}:{@port}/{@db}?user={@user}&password={@pass}&useSSL=false"
    execute "CREATE TABLE `{@table}_testconnect` (`connect` int(11))" in {sql}
    execute "CREATE TABLE IF NOT EXISTS `{@table}_reports` ( `time` INT NOT NULL , `game` VARCHAR(10) NOT NULL DEFAULT 'unknown' , `server` VARCHAR(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'Nieznany' , `reporter` VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'Nieznany' , `reported` VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'Nieznany' , `reason` VARCHAR(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL )" in {sql}
    execute "INSERT INTO `{@table}_testconnect` (`connect`) VALUES ('1')" in {sql}
    execute "SELECT connect FROM `{@table}_testconnect`" in {sql} and store the result in {output::*}
    if "%{output::connect::*}%" is "1":
        send "{@prefix} {@infocolor}Nawiązano połączenie z MySQL!" to console
        set {connected} to "yes"
    else:
        send "{@prefix} {@errorcolor}Nie nawiązano połączenia z MySQL!" to console
        set {connected} to "no"
    execute "DROP TABLE `{@table}_testconnect`" in {sql}

command /{@command} <text="help"> [<player>] [<text>]:
    trigger:
        if arg 1 is "help":
            send "{@accentcolor}+---------&r{@prefix}&r{@accentcolor}---------+"
            send ""
            send "{@accentcolor}/{@command} help &8- {@messagecolor}Wyświetla Pomoc"
            send "{@accentcolor}/{@command} report <gracz> <powód> &8- {@messagecolor}Wysyła zgłoszenie na Gracza"
            send ""
            send "{@accentcolor}+---------&r{@prefix}&r{@accentcolor}---------+"
        if arg 1 is "report":
            if arg 2 is not set:
                send "{@prefix} {@errorcolor}Nie ma takiego Gracza na Serwerze!"
            else:
                loop all players:
                    if name of loop-player is arg 2:
                        if arg 3 is not set:
                            send "{@prefix} {@errorcolor}Podaj powód!"
                        else:
                            if "%{connected}%" is "yes":
                                set {player} to player
                                set {time} to convert date now to unix date
                                execute "INSERT INTO `{@table}_reports` (`time`,`game`,`server`,`reporter`,`reported`,`reason`) VALUES ('%{time}%','{@game}','{@server}','%{player}%','%arg-2%','%arg-3%')" in {sql}
                                send "{@prefix} {@infocolor}Zgłoszono Gracza {@accentcolor}%arg-2% {@infocolor}za {@accentcolor}%arg-3%{@infocolor}!"
                            else:
                                send "{@prefix} {@errorcolor}Wystąpił błąd przy wysyłaniu Zgłoszenia! Skontaktuj się z Administratorem!"
                        stop

My problem is: `execute` command on line 63 theoretically should work (I checked from skript and MySQL side) but... It doesn't send it to MySQL...
WTH is wrong? skript-db is bugged or something else?
 
Last edited:
I was wrote a MySQL Report system using skript-db and skUtilities with connect checking...
code_language.skript:
# MultiGameReportSystem
# Autor: DavivaD
# Opis: Skript po poprawnym /zglos wysyła informację o zgłoszeniu do bazy danych MySQL do wyświetlenia ich na stronie WWW ###
# Wymagane moduły: skript-db, skUtilities

# OPCJE
options:
    # BAZA DANYCH
    host: hosting.pukawka.pl               # Adres Bazy
    port: 3306               # Port Bazy (Domyślnie: 3306)
    user: thecich_677352               # Login
    pass: *****               # Hasło
    db: 677352               # Nazwa Bazy
    table: mgrs               # Prefiks Tabeli (Domyślnie: mgrs)
    # ZGŁOSZENIE
    game: mc               # Typ Gry (Domyślnie: mc)
    server: <span style=""color: red;"">1.11.2</span> Survival+Gildie           # Wyświetlana nazwa Serwera (HTML Dozwolone)
    # CHAT
    prefix: &8[&9Zgłoszenie&8]           # Prefiks Wiadomości (Domyślnie: [MGRS])
    messagecolor: &f       # Kolor Wiadomości (Domyślnie: &f)
    errorcolor: &c           # Kolor Błędu (Domyślnie: &c)
    infocolor: &a           # Kolor Informacji (Domyślnie: &a)
    accentcolor: &9   # Akcentowany Kolor
    command: mgrs       # Nazwa Komendy (Domyślnie: mgrs)
 
on script load:
    set {output::*} to "<none>"
    set {sql} to the database "mysql://{@host}:{@port}/{@db}?user={@user}&password={@pass}&useSSL=false"
    execute "CREATE TABLE `{@table}_testconnect` (`connect` int(11))" in {sql}
    execute "CREATE TABLE IF NOT EXISTS `{@table}_reports` ( `time` INT NOT NULL , `game` VARCHAR(10) NOT NULL DEFAULT 'unknown' , `server` VARCHAR(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'Nieznany' , `reporter` VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'Nieznany' , `reported` VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'Nieznany' , `reason` VARCHAR(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL )" in {sql}
    execute "INSERT INTO `{@table}_testconnect` (`connect`) VALUES ('1')" in {sql}
    execute "SELECT connect FROM `{@table}_testconnect`" in {sql} and store the result in {output::*}
    if "%{output::connect::*}%" is "1":
        send "{@prefix} {@infocolor}Nawiązano połączenie z MySQL!" to console
        set {connected} to "yes"
    else:
        send "{@prefix} {@errorcolor}Nie nawiązano połączenia z MySQL!" to console
        set {connected} to "no"
    execute "DROP TABLE `{@table}_testconnect`" in {sql}

command /{@command} <text="help"> [<player>] [<text>]:
    trigger:
        if arg 1 is "help":
            send "{@accentcolor}+---------&r{@prefix}&r{@accentcolor}---------+"
            send ""
            send "{@accentcolor}/{@command} help &8- {@messagecolor}Wyświetla Pomoc"
            send "{@accentcolor}/{@command} report <gracz> <powód> &8- {@messagecolor}Wysyła zgłoszenie na Gracza"
            send ""
            send "{@accentcolor}+---------&r{@prefix}&r{@accentcolor}---------+"
        if arg 1 is "report":
            if arg 2 is not set:
                send "{@prefix} {@errorcolor}Nie ma takiego Gracza na Serwerze!"
            else:
                loop all players:
                    if name of loop-player is arg 2:
                        if arg 3 is not set:
                            send "{@prefix} {@errorcolor}Podaj powód!"
                        else:
                            if "%{connected}%" is "yes":
                                set {player} to player
                                set {time} to convert date now to unix date
                                execute "INSERT INTO `{@table}_reports` (`time`,`game`,`server`,`reporter`,`reported`,`reason`) VALUES ('%{time}%','{@game}','{@server}','%{player}%','%arg-2%','%arg-3%')" in {sql}
                                send "{@prefix} {@infocolor}Zgłoszono Gracza {@accentcolor}%arg-2% {@infocolor}za {@accentcolor}%arg-3%{@infocolor}!"
                            else:
                                send "{@prefix} {@errorcolor}Wystąpił błąd przy wysyłaniu Zgłoszenia! Skontaktuj się z Administratorem!"
                        stop

My problem is: `execute` command on line 63 theoretically should work (I checked from skript and MySQL side) but... It doesn't send it to MySQL...
WTH is wrong? skript-db is bugged or something else?
remove the ' around the values, skript-db will automatically arrange expressions (barring the unsafe expression which is, well, unsafe) into prepared statements to mitigate sql injection
 
Status
Not open for further replies.