SA-MP Forums Archive
Mysql help! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Mysql help! (/showthread.php?tid=488605)



Mysql help! - ewida - 18.01.2014

Hello guys, When I compile my MySQL Gamemode it give me this error.

pawn Код:
********.pwn(21508) : error 017: undefined symbol "mysql_escape_string"
This line "21508"

pawn Код:
mysql_escape_string(accountName, tmpName, MainPipeline);
And this all the Script in that line (its a command)

pawn Код:
CMD:changeuserpin(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 1337)
    {
        SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
        return 1;
    }

    new string[128], accountName[20], password[64], query[512];
    if(sscanf(params, "s[20]s[64]", accountName, password))
        return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /changeuserpin [player name] [new pin]");

    if(strlen(password) > 4 || !IsNumeric(password))
        return SendClientMessageEx(playerid, COLOR_GREY, "The pin must be numbers, and must have 4 digits.");

    new passbuffer[129];
    WP_Hash(passbuffer, sizeof(passbuffer), password);

    format(string, sizeof(string), "Attempting to change %s's pin...", accountName);
    SendClientMessageEx(playerid, COLOR_YELLOW, string);

    format(string, sizeof(string), "AdmCmd: %s's pin was changed by %s.", accountName, GetPlayerNameEx(playerid));
    Log("logs/pin.log", string);

    SetPVarInt(playerid, "ChangePin", 1);

    new tmpName[24];
    mysql_escape_string(accountName, tmpName, MainPipeline);

    format(query,sizeof(query),"UPDATE `accounts` SET `Pin`='%s' WHERE `Username`='%s' AND `AdminLevel` < 2",passbuffer,tmpName);
    mysql_function_query(MainPipeline, query, false, "OnChangeUserPassword", "i", playerid);
    SetPVarString(playerid, "OnChangeUserPassword", tmpName);
    return 1;
}
At the top of Gamemode there
pawn Код:
#include <a_mysql>
- Thanks for Help +rep!


Re: Mysql help! - Nourdin - 18.01.2014

Do you have the MYSQL updated? And are you sure you're using the correct MYSQL plugins?


Re: Mysql help! - Smally - 18.01.2014

I believe it is mysql_real_escape_string not mysql_escape_string


Re: Mysql help! - ewida - 18.01.2014

I have MySQL plugin (MySQL.dll and at server.cfg near "plugins" there "MySQL") and I have MySQL Include.


Respuesta: Re: Mysql help! - Stront - 18.01.2014

Quote:
Originally Posted by Smally
Посмотреть сообщение
I believe it is mysql_real_escape_string not mysql_escape_string
Surely I am.


Re: Mysql help! - ewida - 18.01.2014

Quote:
Originally Posted by Smally
Посмотреть сообщение
I believe it is mysql_real_escape_string not mysql_escape_string
its works, Thank you + rep!


Re: Mysql help! - ewida - 18.01.2014

All good, now got that errors,

pawn Код:
*****.pwn(182) : error 017: undefined symbol "mysql_errno"
Line "182"

pawn Код:
if(mysql_errno(MainPipeline) != 0)
All the Script>

pawn Код:
stock g_mysql_Init()
{
    new SQL_HOST[64], SQL_DB[64], SQL_USER[32], SQL_PASS[128], SQL_DEBUG, SQL_DEBUGLOG;
    new SQL_SHOST[64], SQL_SDB[64], SQL_SUSER[32], SQL_SPASS[128];
    new fileString[128], File: fileHandle = fopen("mysql.cfg", io_read);

    while(fread(fileHandle, fileString, sizeof(fileString))) {
        if(ini_GetValue(fileString, "HOST", SQL_HOST, sizeof(SQL_HOST))) continue;
        if(ini_GetValue(fileString, "DB", SQL_DB, sizeof(SQL_DB))) continue;
        if(ini_GetValue(fileString, "USER", SQL_USER, sizeof(SQL_USER))) continue;
        if(ini_GetValue(fileString, "PASS", SQL_PASS, sizeof(SQL_PASS))) continue;
        if(ini_GetInt(fileString, "SHOPAUTOMATED", ShopToggle)) continue;
        if(ini_GetValue(fileString, "SHOST", SQL_SHOST, sizeof(SQL_SHOST))) continue;
        if(ini_GetValue(fileString, "SDB", SQL_SDB, sizeof(SQL_SDB))) continue;
        if(ini_GetValue(fileString, "SUSER", SQL_SUSER, sizeof(SQL_SUSER))) continue;
        if(ini_GetValue(fileString, "SPASS", SQL_SPASS, sizeof(SQL_SPASS))) continue;
        if(ini_GetInt(fileString, "SERVER", servernumber)) continue;
        if(ini_GetInt(fileString, "DEBUG", SQL_DEBUG)) continue;
        if(ini_GetInt(fileString, "DEBUGLOG", SQL_DEBUGLOG)) continue;
    }
    fclose(fileHandle);

    mysql_log(SQL_DEBUG, SQL_DEBUGLOG);
    MainPipeline = mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);

    printf("[MySQL] (Main Pipelines) Connecting to %s...", SQL_HOST);
    if(mysql_errno(MainPipeline) != 0)
    {
        printf("[MySQL] (MainPipeline) Fatal Error! Could not connect to MySQL: Host %s - DB: %s - User: %s", SQL_HOST, SQL_DB, SQL_USER);
        print("[MySQL] Note: Make sure that you have provided the correct connection credentials.");
        printf("[MySQL] Error number: %d", mysql_errno(MainPipeline));
        SendRconCommand("exit");
    }
    else print("[MySQL] (MainPipeline) Connection successful toward MySQL Database Server!");

    if(ShopToggle == 1)
    {
        ShopPipeline = mysql_connect(SQL_SHOST, SQL_SUSER, SQL_SDB, SQL_SPASS);

        printf("[MySQL] (Shop Pipelines) Connecting to %s...", SQL_SHOST);
        if(mysql_errno(ShopPipeline) != 0)
        {
            printf("[MySQL] (ShopPipeline) Fatal Error! Could not connect to MySQL: Host %s - DB: %s - User: %s", SQL_SHOST, SQL_SDB, SQL_SUSER);
            print("[MySQL] Note: Make sure that you have provided the correct connection credentials.");
            printf("[MySQL] Error number: %d", mysql_errno(ShopPipeline));
            //SendRconCommand("exit");
        }
        else print("[MySQL] (ShopPipeline) Connection successful toward MySQL Database Server!");
    }
   
    InitiateGamemode(); // Start the server

    return 1;
}
Thx for help +rep!


Re: Mysql help! - Smally - 18.01.2014

Can Only assume that mysql_errno is only made for query errors!