Mysql problem
#1

I'm starting to use mysql but i have this problem

pawn Код:
error 017: undefined symbol  "mysql_query"
Can anyone help me?
Reply
#2

Most of the released scripts use an older version of MySQL and actually with no threaded queries. Your plugin and include is fine, you just need to update those scripts to threaded queries. Take a look at this tutorial: https://sampforum.blast.hk/showthread.php?tid=337810
Reply
#3

If you don't know anything about BlueG's MySQL R7, then stick with R6, threaded queries are more harder than what you think. if you want to learn about it then check the link given by Konstantinos

While I'm searching for your problem, Vince stated the same as what I said above

Quote:
Originally Posted by Vince
Посмотреть сообщение
You'll have to rebuild it, because there's no more support for unthreaded queries. If you don't want to rebuild it, you need to go back to R6-2. I do not recommend it. Read AndreT's tutorial in the tutorial section.
Reply
#4

Ok thanks i'm using R6

Can anyone tell me how to fix this

pawn Код:
public OnPlayerConnect(playerid)
{
    new Query[80],string[128];
    format(Query,sizeof(Query),"SELECT `Username` FROM `Users` WHERE `Username` = `%s` LIMIT 1;",GetName(playerid));
    mysql_query(Query);
    mysql_store_result();
    if(mysql_num_rows() != 0)
    {
        format(string,sizeof(string),"Hey, %s! \nYour account is registered.\nPlease enter the password to log in!",GetName(playerid));
        ShowPlayerDialog(playerid,0,DIALOG_STYLE_INPUT,"Login",string,"Login","Quit");
    }
    else
    {
        format(string,sizeof(string),"Hey, %s! \nYour account is not registered. \nPlease register to continue!",GetName(playerid));
        ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"Register",string,"Register","Quit");
    }
    mysql_free_result();
    return 1;
}
i'm not registered but it show me the dialog login.
Reply
#5

anybody know a good method to have ur DB work with Volt-host>?
Reply
#6

Try this:
pawn Код:
public OnPlayerConnect(playerid)
{
    new Query[80],string[128];
    format(Query,sizeof(Query),"SELECT * FROM `Users` WHERE `Username` = `%s` LIMIT 1;",GetName(playerid));
    mysql_query(Query);
    mysql_store_result();
    if(mysql_num_rows() > 0)
    {
        format(string,sizeof(string),"Hey, %s! \nYour account is registered.\nPlease enter the password to log in!",GetName(playerid));
        ShowPlayerDialog(playerid,0,DIALOG_STYLE_INPUT,"Login",string,"Login","Quit");
    }
    else
    {
        format(string,sizeof(string),"Hey, %s! \nYour account is not registered. \nPlease register to continue!",GetName(playerid));
        ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"Register",string,"Register","Quit");
    }
    mysql_free_result();
    return 1;
}
Reply
#7

This don't work to. When i registered and type command /q to quit going again in my server it show me the dialog register again don't show the dialog login

here's the full code

pawn Код:
#include <a_samp>
#include <sscanf2>
#include <a_mysql>

#undef MAX_PLAYERS
#define MAX_PLAYERS 30

#define mysql_host "localhost"
#define mysql_user "root"
#define mysql_password ""
#define mysql_database "users"

enum PlayerInfo
{
    Username[23],
    Password[24],
    Money
}
new PInfo[MAX_PLAYERS][PlayerInfo];

main() {}

public OnGameModeInit()
{
    mysql_connect(mysql_host,mysql_user,mysql_database ,mysql_password);
    return 1;
}

public OnPlayerConnect(playerid)
{
    new Query[80],pName[24],string[164];
    GetPlayerName(playerid,pName,24);
    format(Query,sizeof(Query),"SELECT `Username` FROM `Users` WHERE `Username` = '%s' LIMIT 1;",pName);
    mysql_query(Query);
    mysql_store_result();
    if(mysql_num_rows() > 0)
    {
        format(string,sizeof(string),"Hey, %s! \nYour account is registered.\nPlease enter the password to log in!",pName);
        ShowPlayerDialog(playerid,0,DIALOG_STYLE_INPUT,"Lo g in",string,"Login","");
    }
    else
    {
        format(string,sizeof(string),"Hey, %s! \nYour account is not registered. \nPlease register to continue!",pName);
        ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"Re gister",string,"Register","");
    }
    mysql_free_result();
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1)
    {
        if(!response) return Kick(playerid);
        if(response)
        {
            if(strlen(inputtext) == 0)
            {
            ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"Register - Enter your password","You are about to register a new account! \nPlease choose the password for it! \n","Register!","");
            }
            else
            {
                new EscapedText[60],Query[80],pName[24];
                mysql_real_escape_string(inputtext, EscapedText);
                GetPlayerName(playerid,pName,sizeof(pName));
                format(Query,sizeof(Query),"INSERT INTO `Users` (Username,Password,Money) VALUES ('%s','%s,'0')",pName,(playerid),EscapedText);
                mysql_query(Query);
                SendClientMessage(playerid,-1,"You have been successfully registered!");
                GivePlayerMoney(playerid,5000);
                SetPlayerScore(playerid,100);
            }
        }
    }
    if(dialogid == 0)
    {
        if(!response) return Kick(playerid);
        if(response)
        {
            if(strlen(inputtext) == 0)
            {
            ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"Register - Enter your password","You are about to register a new account! \nPlease choose the password for it! \n","Register!","");
            }
            else
            {
                LoginPlayer(playerid,inputtext);
            }
        }
    }
    return 1;
}

stock LoginPlayer(playerid,const password[])
{
    new EscapedText[60],Query[80],pname[24];
    mysql_real_escape_string(password, EscapedText);
    GetPlayerName(playerid,pname,sizeof(pname));
    format(Query,sizeof(Query),"SELECT * FROM `Users` WHERE `Username` = '%s' AND `Password` = '%s'",pname,EscapedText);
    mysql_query(Query);
    mysql_store_result();
    if(mysql_num_rows() > 0)
    {
        SendClientMessage(playerid,-1,"You have been logged in!");
        LoadStats(playerid);
    }
    else
    {
        SendClientMessage(playerid,-1,"Wrong password!");
        Kick(playerid);
    }
    mysql_free_result();
    return 1;
}

stock LoadStats(playerid)
{
    new pName[24],Query[80];
    GetPlayerName(playerid,pName,24);
    format(Query, sizeof(Query), "SELECT * FROM `Users` WHERE `Username` = '%s' ", pName);
    mysql_query(Query);
    mysql_store_result();
    mysql_fetch_row_format(Query, "|");
    sscanf(Query, "e<p<|>s[24]s[23]i>", PInfo[playerid]);
    mysql_free_result();
    GivePlayerMoney(playerid,PInfo[playerid][Money]);
    return 1;
}
and 1 more question
pawn Код:
#define mysql_database "users" // this is the database exported to my computer like database.sql or the one on the phpmyadmin?
Reply
#8

Check mysql log. Does the table/database exist?
Reply
#9

I don't have a mysql log.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)